预测'tslm'收到未使用的参数错误

时间:2019-01-30 19:59:15

标签: r time-series forecast

这是我的代码:

library(forecast)
oldstuff<-read.table(text="Week Forecast     Actual prevAccuracy
                 49 2018-12-03  6775906  280215.00   0.01723065
                 50 2018-12-10  3659630  740035.90   0.05604323
                 51 2018-12-17  4009861       0.00   0.22264551
                 52 2018-12-24  4262533   92620.51   0.24447944
                 53 2018-12-31  4463402 3109617.17   0.19740596
                 54 2019-01-07  4786782 1881454.00   0.02625039
                 55 2019-01-14  4771027 1091031.00   0.02115797
                 56 2019-01-21  5382587 5095186.83   0.06343317")
newstuff<-read.table(text="  Week Forecast prevAccuracy
                     57 2019-01-28  1124392    0.8382692
                     58 2019-02-04  2161792    0.9130823
                     59 2019-02-11  2480092    0.6848097
                     60 2019-02-18  3197242    0.6848097")
oldstuffts<- ts(oldstuff, freq=365.25/7, start=2018 + 337/365.25)
oldstuffmodel <- tslm(Actual~Forecast + prevAccuracy, data=oldstuffts)
forecast(oldstuffmodel, newdata=newstuff)

当我尝试预测模型时,出现此错误:

Error in forecast(oldstuffmodel, newdata = newstuff) : 
  unused argument (newdata = newstuff)

如何使预测功能正常工作?

1 个答案:

答案 0 :(得分:1)

显然,使用了其他软件包中的forecast函数。相反,您可以指定要使用forecast软件包中的一个:

forecast::forecast(oldstuffmodel, newdata = newstuff)
#          Point Forecast     Lo 80   Hi 80     Lo 95    Hi 95
# 2019.076      -921205.5 -10112280 8269869 -16929516 15087105
# 2019.095      -930932.3 -11151447 9289583 -18732243 16870378
# 2019.114      -304598.4  -7883188 7273991 -13504405 12895208
# 2019.133      -181770.1  -7936566 7573026 -13688480 13324940