It has been well-known since at least 1969, when Bates and Granger wrote their famous paper on “The Combination of Forecasts”, that combining forecasts often leads to better forecast accuracy.
So it is helpful to have a couple of new R packages which do just that: opera and forecastHybrid.
opera
Opera stands for “Online Prediction by ExpeRt Aggregation”. It was written by Pierre Gaillard and Yannig Goude, and Pierre provides a nice introduction in the vignette. While it can be used with combining any sort of predictions, I will just consider simple univariate time series forecasts, using the monthly co2 data.
It begins with weighting each forecast method equally, quickly drops the ARIMA method, and then switches to STL alone. But by the end of the test set, it is giving weight 0 to ETS, 1 to ARIMA and 0 to STL. Here are the resulting forecasts:
z <-ts(predict(MLpol0, X, test, type='response'), start=c(1991,1), freq=12)df <-cbind(co2, z)colnames(df) <-c("Data","Mixture")autoplot(df) +xlab("Year") +ylab(expression("Atmospheric concentration of CO"[2]))
forecastHybrid
The forecastHybrid package from David Shaub and Peter Ellis fits multiple models from the forecast package and then combines them using either equal weights, or weights based on in-sample errors. By default, the models combined are from the auto.arima, ets, nnetar, stlm and tbats functions. David Shaub provides a helpful vignette explaining how to use the package.
Those prediction intervals look dodgy because they are way too conservative. The package is taking the widest possible intervals that includes all the intervals produced by the individual models. So you only need one bad model, and the prediction intervals are screwed. To compute prediction intervals with the required coverage, it would be necessary to estimate the covariances between the different forecast errors, and then find the resulting variance expression for the linear combination of methods.
The combination point forecasts look much better:
df <-cbind(Data=co2, Hybrid1=fc1$mean, Hybrid2=fc2$mean)autoplot(df) +xlab("Year") +ylab(expression("Atmospheric concentration of CO"[2]))
Note that the weights are not being updated, unlike with the opera package. In this particular example, the opera forecasts are doing substantially better:
It should be noted, however, that the opera weights are updated using the past test data, while the forecastHybrid weights are based only on the training data. So this comparison is not entirely “fair”.
Also, all of these results are much better than any of the individual forecasting methods: