具有2个以上状态的马尔可夫切换模型MSwM

时间:2015-05-19 13:11:31

标签: r markov

有没有人尝试使用'MSwM'运行马尔可夫转换模型并设置超过2种制度?有三个它似乎不起作用

数据(r_t)

[1]  0.0000000000 -0.0101170400 -0.0016032060 -0.0071256520  0.0007075710 -0.0021212120  0.0021257210 -0.0013131310 -0.0003034290 -0.0014164310  0.0026342450  0.0014147130
[13]  0.0039354190 -0.0019097400 -0.0018126890 -0.0015133170 -0.0059614020 -0.0055905670  0.0049064700 -0.0009663310  0.0000509087 -0.0146609650  0.0007232900 -0.0010325250
[25]  0.0043410850 -0.0027271790  0.0031474120  0.0004114800 -0.0002056560 -0.0016455830  0.0044297930 -0.0138461540  0.0017680710  0.0021802330 -0.0063203150 -0.0039605960
[37] -0.0036633870 -0.0042021220  0.0033231350 -0.0078334470 -0.0027554050 -0.0010626990 -0.0079787230 -0.0007506700 -0.0004561060  0.0008857870 -0.0026818280 -0.0034419710
[49]  0.0012951970 -0.0012935220 -0.0024284940 -0.0154179060  0.0032967030  0.0029572840  0.0160532930  0.0049441100  0.0033689840 -0.0026115230  0.0023511810  0.0021324230
[61] -0.0034046180  0.0002135160  0.0001601020  0.0020809990 -0.0115015970 -0.0068950660  0.0070514210 -0.0066788750 -0.0012471530  0.0017916280 -0.0028181230  0.0039130430
[73]  0.0015158080  0.0000000000  0.0023243240 -0.0023189340  0.0019459460 -0.0002157960 -0.0014569390 -0.0056741420  0.0054347830 -0.0054054050  0.0010869570  0.0014115090
[85]  0.0018432180 -0.0064935060  0.0032679740  0.0043431050 -0.0008648650 -0.0011902190  0.0021666130 -0.0055129180  0.0000000000  0.0000000000 -0.0367391300 -0.0230196340
[97] -0.0600600600  0.0788891620  0.0127562640 -0.0008996850

代码

model=glm(r_t ~ 1)
mod = msmFit(model, k = 3, p = 1, sw = rep(TRUE, 3))

错误消息

Error in std[i] = summary(mod1)$sigma : replacement has length zero

1 个答案:

答案 0 :(得分:0)

这与州的数量无关。 msmFit(model, k = 2, p = 1, sw = rep(TRUE, 3))也不起作用。

这里的问题是使用了msmFit的错误方法。使用glm对象的方法代替lm的方法,因为class(model)c("glm", "lm")

解决问题的最简单方法是使用lm代替glm

或者,如果您更喜欢glm方法,则可以明确地将其命名为:

msmFit.glm <- selectMethod(msmFit, c("glm","numeric","logical","ANY","missing","ANY"))
mod = msmFit.glm(model, k = 3, p = 1, sw = rep(TRUE, 2))

请注意,glmlm方法非常不同!有关详细信息,请参阅?"MSM.lm-class"?"MSM.glm-class"