我正在尝试运行以下函数,以便根据this link创建Markov转换模型。
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))
但是第二行代码给我以下错误:
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘msmFit’ for signature ‘"matrix", "numeric", "logical", "missing", "missing", "missing"’
有人可以帮我解决此问题吗?非常感谢你。 我使用的数据是here。
答案 0 :(得分:0)
您的OLS规范似乎太复杂:msmFit中的olsY应该属于(g)lm或“ formula”类,因此只需以这种方式重写代码的第一部分即可
olsY = lm(persons ~ vocMean + ble + cal + weekday, data = data)