简体   繁体   English

使用组合预测(auto.arima())

[英]Using the combination forecast(auto.arima())

I recently updated to forecast() version 4.03 and the last line (line 4) of the example code below now gives an error message (as shown at the bottom). 我最近更新到forecast()版本4.03,下面示例代码的最后一行(第4行)现在给出了一条错误消息(如底部所示)。 Notice that forecast() in line 4 is fed the output of auto.arima() from line 3 (which works without any errors). 请注意,第4行中的forecast()从第3行输入auto.arima()(它没有任何错误)。 Has something changed in the forecast package? 预测包中有什么变化吗?

In addition, the error message disappears when the zoo term in line 3 is replaced with a ts term using the following code: 此外,当使用以下代码将第3行中的zoo术语替换为ts术语时,错误消息将消失:

  autarimod <- auto.arima(log(as.ts(zooinpdat))) ##New line 3

So, does the forecast(auto.arima()) combination no longer accept zoo objects? 那么,预测(auto.arima())组合是否不再接受动物园对象? If that's the case, is there a better way to handle this than the as.ts() method? 如果是这种情况,是否有比as.ts()方法更好的方法来处理它?

library(zoo)
library(forecast)

inpdat <- c(353.03, 383.06, 407.9, 420.58, 345.96, 299.73, 286.42, 291.03, 
  297.71, 300.92, 272.13, 283.58, 331.72, 372.95, 404.78, 403.04, 
  374.57, 332.94, 284.37, 311.78, 307.27, 302.42, 283.52, 288.64, 
  337.19, 416.35, 418.65, 431.51, 407.74, 319.28, 297.33, 314.83, 
  290.49, 309.38, 294.5, 330.63, 371.2, 418.76, 440.05, 467.23, 
  384.32, 329.81, 300.4, 318.9, 355.06, 329.93, 293.43, 297.76, 
  340.42, 393.09, 395.2, 443.13, 396.45, 341.96, 307.95, 322, 339.63, 
  312.12, 304.31, 310.95)

zooinpdat <- zooreg(inpdat, frequency=12, start=as.yearmon("May 1965"))

autarimod <- auto.arima(log(zooinpdat)) ##Line 3

for_arima <- forecast(autarimod, level=0.98, h=48) ##Line 4


Error in .cbind.ts(list(e1, e2), c(deparse(substitute(e1))[1L], deparse(substitute(e2))[1L]),  : 
not all series have the same frequency

The forecast package is intended for ts objects, not zoo objects. 预测包适用于ts对象,而不是zoo对象。 Some functions will work ok with zoo objects, but there are no guarantees. 有些函数可以用于zoo对象,但是没有保证。 In particular, when I make changes to the package, I never check if the changes will cause problems if zoo objects are used. 特别是,当我对包进行更改时,如果使用zoo对象,我永远不会检查更改是否会导致问题。

You can fix your error using 您可以使用修复错误

zooinpdat <- as.ts(zooinpdat)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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