简体   繁体   中英

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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