1

这是我的代码:

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)

如何让预测功能发挥作用?

4

1 回答 1

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
于 2019-01-30T20:02:38.937 回答