Reputation: 4750
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). Notice that forecast() in line 4 is fed the output of auto.arima() from line 3 (which works without any errors). 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:
autarimod <- auto.arima(log(as.ts(zooinpdat))) ##New line 3
So, does the forecast(auto.arima()) combination no longer accept zoo objects? If that's the case, is there a better way to handle this than the as.ts() method?
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
Upvotes: 1
Views: 2278
Reputation: 31800
The forecast package is intended for ts
objects, not zoo
objects. Some functions will work ok with zoo
objects, but there are no guarantees. In particular, when I make changes to the package, I never check if the changes will cause problems if zoo
objects are used.
You can fix your error using
zooinpdat <- as.ts(zooinpdat)
Upvotes: 4