Bagging a time series using ARIMA

I've tried to adapt the code in the example of section 12.5 Bootstrapping and bagging of the FPP3 textbook to use an ARIMA model for bagging the time series rather than an ETS model. However, I am getting the error "'x' must be a vector of an atomic type". Is ARIMA not compatible with this kind of bagging or do I just need to modify something?

(Ultimately, I'm interested in using various models to bag bootstrapped time series and then to take the simple average of them, similar to the example in 13.4 Forecast Combinations.)

library(fpp3)

cement <- aus_production %>%
  filter(year(Quarter) >= 1988) %>%
  select(Quarter, Cement)
cement_stl <- cement %>%
  model(stl = STL(Cement))
cement_stl %>%
  components() %>%
  autoplot()

cement_stl %>%
  generate(new_data = cement, times = 10,
           bootstrap_block_size = 8) %>%
  autoplot(.sim) +
  autolayer(cement, Cement) +
  guides(colour = "none") +
  labs(title = "Cement production: Bootstrapped series",
       y="Tonnes ('000)")

sim <- cement_stl %>%
  generate(new_data = cement, times = 100,
           bootstrap_block_size = 8) %>%
  select(-.model, -Cement)

arima_forecasts <- sim %>%
  model(arima = ARIMA(.sim)) %>%
  forecast(h = 12)
arima_forecasts %>%
  update_tsibble(key = .rep) %>%
  autoplot(.mean) +
  autolayer(cement, Cement) +
  guides(col = FALSE) +
  labs(title = "Cement production: bootstrapped forecasts",
       y="Tonnes ('000)")

bagged <- arima_forecasts %>%
  summarise(bagged_mean = mean(.mean))
cement %>%
  model(arima = ARIMA(Cement)) %>%
  forecast(h = 12) %>%
  autoplot(cement) +
  autolayer(bagged, bagged_mean, col = "#D55E00") +
  labs(title = "Cement production in Australia",
       y="Tonnes ('000)")

Referred here by Forecasting: Principles and Practice, by Rob J Hyndman and George Athanasopoulos

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.