Combine forecasts from mvgam models into evenly weighted ensembles
Combine forecasts from mvgam models into evenly weighted ensembles
Generate evenly weighted ensemble forecast distributions from mvgam_forecast objects
ensemble(object,...)## S3 method for class 'mvgam_forecast'ensemble(object,..., ndraws =5000)
Arguments
object: list object of class mvgam_forecast. See forecast.mvgam()
...: More mvgam_forecast objects.
ndraws: Positive integer specifying the number of draws to use from each forecast distribution for creating the ensemble. If some of the ensemble members have fewer draws than ndraws, their forecast distributions will be resampled with replacement to achieve the correct number of draws
Returns
An object of class mvgam_forecast containing the ensemble predictions. This object can be readily used with the supplied S3 functions plot and score
Details
It is widely recognised in the forecasting literature that combining forecasts from different models often results in improved forecast accuracy. The simplest way to create an ensemble is to use evenly weighted combinations of forecasts from the different models. This is straightforward to do in a Bayesian setting with mvgam as the posterior MCMC draws contained in each mvgam_forecast object will already implicitly capture correlations among the temporal posterior predictions.
Examples
# Simulate some series and fit a few competing dynamic modelsset.seed(1)simdat <- sim_mvgam(n_series =1, prop_trend =0.6, mu =1)plot_mvgam_series(data = simdat$data_train, newdata = simdat$data_test)m1 <- mvgam(y ~1, trend_formula =~ time + s(season, bs ='cc', k =9), trend_model = AR(p =1), noncentred =TRUE, data = simdat$data_train, newdata = simdat$data_test, chains =2, silent =2)m2 <- mvgam(y ~ time, trend_model = RW(), noncentred =TRUE, data = simdat$data_train, newdata = simdat$data_test, chains =2, silent =2)# Calculate forecast distributions for each modelfc1 <- forecast(m1)fc2 <- forecast(m2)# Generate the ensemble forecastensemble_fc <- ensemble(fc1, fc2)# Plot forecastsplot(fc1)plot(fc2)plot(ensemble_fc)# Score forecastsscore(fc1)score(fc2)score(ensemble_fc)