简体   繁体   English

R 中的 MSwM(马尔可夫切换模型)函数不起作用

[英]MSwM (Markov-Switching Model) function in R not working

I am trying to run the function below in order to create a Markov-Switching Model according to this link .我正在尝试运行下面的函数,以便根据此链接创建马尔可夫切换模型。

olsY = model.matrix(persons ~ vocMean + ble + cal + weekday, model.frame(lm(persons ~ vocMean + ble + cal + weekday, data = data)))

msY = msmFit(olsY, k = 2, sw = rep(TRUE, 5))

But the second line of code gives me the following error:但是第二行代码给了我以下错误:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘msmFit’ for signature ‘"matrix", "numeric", "logical", "missing", "missing", "missing"’

Can someone please help me fix this issue?有人可以帮我解决这个问题吗? Thank you very much.非常感谢。 The data I used is here .我使用的数据在这里

看来你的OLS规范太复杂了:msmFit中的olsY应该属于(g)lm或者"formula"类,所以就用这种方式重写你的第一部分代码

olsY = lm(persons ~ vocMean + ble + cal + weekday, data = data)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM