[英]How to predict next month given a fitted model?
假设我已经为数据安装了 GAM model:
model <- gam(Cases~s(Time, k=5, bs="cs"), data=dengue, family = gaussian(link = indentity))
数据长达 32 周。 我如何预测接下来的 4 周(第 33 至第 36 周)?
prediction <- predict(model, se.fit=T, n.ahead=4)
也许是这样的? 提前致谢。
您必须为predict()
提供新数据的数据框才能进行预测。 有关详细信息,请参阅文档。
在您的情况下,这意味着:
testdata = data.frame(Time= c(33:36))
prediction <- predict(model, newdata = testdata)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.