Skip to main content

Note 23: Ensemble Forecasting & Monte Carlo Uncertainty Simulation

Module 5: State-Space & Ensembles

library(fpp3)

Learning Objectives

  • Formulate equal-weight and custom-weighted forecast combinations and explain how imperfect error correlation reduces forecast variance.
  • State the distributional assumptions fable uses when combining forecast models analytically, and recognize when Monte Carlo simulation is required.
  • Generate fast Monte Carlo future sample paths with generate() and construct horizon-specific empirical fan intervals.
  • Evaluate individual models and ensembles out of sample on tourism and production benchmarks using RMSE, MAE, MASE, and CRPS.

1. Why Forecast Combinations Work

Given \(m\) candidate models producing \(h\)-step forecasts \(\hat{y}_{T+h \mid T}^{(1)}, \dots, \hat{y}_{T+h \mid T}^{(m)}\), a linear ensemble (combination) forecast takes a convex weighted average:

\[ \hat{y}_{T+h \mid T}^{\text{ens}} = \sum_{i=1}^m w_i \, \hat{y}_{T+h \mid T}^{(i)}, \qquad w_i \ge 0, \quad \sum_{i=1}^m w_i = 1. \]

Why does combining diverse models consistently rival or beat selecting a single winner? Consider two unbiased models with forecast errors \(e_1, e_2\), variances \(\sigma_1^2, \sigma_2^2\), and correlation \(\rho\):

\[ \operatorname{Var}(e_{\text{ens}}) = w^2 \sigma_1^2 + (1 - w)^2 \sigma_2^2 + 2 w (1 - w) \rho \sigma_1 \sigma_2. \]

Whenever \(\rho < 1\), the ensemble error variance is strictly smaller than the weighted average of the individual variances. Combining genuinely distinct model families (such as state-space ETS, autoregressive ARIMA, and a seasonal benchmark SNAIVE) hedges against specification risk: when one model misreads a recent shift or seasonal pattern, another stabilizes the prediction. Remarkably, simple equal weights (\(w_i = 1/m\)) often match complex estimated weights because weight-estimation noise can offset theoretical gains on short time series.

How fable Combines Forecast Distributions

In fable, writing mutate(ens = (ets + arima) / 2) combines both point forecasts and forecast distributions. Analytically, fable assumes the component forecast errors are jointly Gaussian and estimates their cross-model error correlation from the training residuals to compute the combined variance. Two caveats follow immediately:

  • Untransformed vs. transformed models: Analytical linear combination works cleanly when all component models produce normal forecast distributions on the same scale. If any component uses a nonlinear response transformation (such as box_cox() or log()), the sum of transformed and untransformed distributions has no closed-form normal distribution, causing fable to fall back to a degenerate point mass unless you simulate trajectories.
  • Non-Gaussian or multiplicative uncertainty: When innovation distributions are skewed, heavy-tailed, or nonlinear (as in multiplicative ETS), Monte Carlo simulation via generate() offers a flexible alternative for constructing exact empirical forecast distributions.

2. Out-of-Sample Ensemble Benchmarks

Worked Example 1: Sydney Holiday Tourism

We split quarterly Sydney Holiday trips (tourism) into training (< 2015 Q1) and a 3-year test horizon (2015 Q1 to 2017 Q4), fitting ETS, ARIMA, SNAIVE, an equal-weight ETS + ARIMA ensemble, and a weighted three-model ensemble.

syd <- tourism |>
  filter(Region == "Sydney", Purpose == "Holiday")

syd_tr <- syd |> filter(Quarter < yearquarter("2015 Q1"))
syd_te <- syd |> filter(Quarter >= yearquarter("2015 Q1"))

fit_syd <- syd_tr |>
  model(
    ets    = ETS(Trips),
    arima  = ARIMA(Trips),
    snaive = SNAIVE(Trips)
  ) |>
  mutate(
    ens_eq = (ets + arima) / 2,
    ens_wt = 0.6 * ets + 0.3 * arima + 0.1 * snaive
  )

fc_syd <- fit_syd |> forecast(new_data = syd_te)

accuracy(fc_syd, syd, measures = list(point_accuracy_measures, CRPS = CRPS)) |>
  select(.model, RMSE, MAE, MASE, CRPS) |>
  arrange(CRPS) |>
  fmt_tbl(digits = 2, caption = "Out-of-sample accuracy on Sydney Holiday trips (2015 Q1-2017 Q4)")
Out-of-sample accuracy on Sydney Holiday trips (2015 Q1-2017 Q4)
.model RMSE MAE MASE CRPS
ets 53.34 45.44 0.58 32.37
ens_wt 53.60 46.01 0.59 32.38
ens_eq 55.51 48.50 0.62 32.99
arima 65.52 57.55 0.74 38.32
snaive 64.11 49.54 0.63 44.90

Without knowing in advance that ETS would outperform ARIMA on the 2015–2017 test split, both ensembles substantially cut error relative to ARIMA and SNAIVE, and ens_wt essentially ties the best individual model on both RMSE (53.6 vs. 53.3) and CRPS (32.4).

Worked Example 2: Australian Cement Production

We next test ensembles on aus_production$Cement (thousands of tonnes, train < 2005 Q1, test 2005 Q1–2010 Q2), keeping all models on the raw scale so fable propagates full probabilistic distributions cleanly.

cem <- aus_production |>
  select(Quarter, Cement) |>
  drop_na()

cem_tr <- cem |> filter(Quarter < yearquarter("2005 Q1"))
cem_te <- cem |> filter(Quarter >= yearquarter("2005 Q1"))

fit_cem <- cem_tr |>
  model(
    ets    = ETS(Cement),
    arima  = ARIMA(Cement),
    snaive = SNAIVE(Cement)
  ) |>
  mutate(
    ens_eq = (ets + arima) / 2,
    ens_wt = 0.6 * ets + 0.3 * arima + 0.1 * snaive
  )

fc_cem <- fit_cem |> forecast(new_data = cem_te)

accuracy(fc_cem, cem, measures = list(point_accuracy_measures, CRPS = CRPS)) |>
  select(.model, RMSE, MAE, MASE, CRPS) |>
  arrange(CRPS) |>
  fmt_tbl(digits = 2, caption = "Out-of-sample ensemble accuracy on Australian Cement (thousands of tonnes)")
Out-of-sample ensemble accuracy on Australian Cement (thousands of tonnes)
.model RMSE MAE MASE CRPS
ets 168.4 144.7 1.49 105.3
ens_wt 194.2 164.1 1.69 114.3
snaive 201.9 162.8 1.68 117.3
ens_eq 208.7 176.4 1.82 123.7
arima 254.9 218.8 2.25 168.7

Again, combining hedges against the weak untransformed ARIMA model (RMSE = 255, CRPS = 169), bringing ens_wt down to RMSE = 194 and CRPS = 114.

3. Monte Carlo Trajectory Simulation & Horizon-Specific Fan Intervals

Rather than relying solely on closed-form Gaussian variance formulas, generate() simulates future sample paths \(\tilde{y}_{T+1}^{(r)}, \dots, \tilde{y}_{T+H}^{(r)}\) (\(r = 1, \dots, R\)) recursively from the fitted state-space or ARIMA innovations. Always set a seed (set.seed()) for reproducibility.

set.seed(493)
sims_syd <- fit_syd |>
  select(ets, arima) |>
  generate(h = "3 years", times = 100, bootstrap = FALSE)

When plotting simulated trajectories across multiple models, map group = interaction(.model, .rep) so each replicate path of each model is drawn as a distinct line with matching legend colors.

sims_syd |>
  ggplot(aes(x = Quarter, y = .sim, group = interaction(.model, .rep), colour = .model)) +
  geom_line(alpha = 0.18, linewidth = 0.45) +
  geom_line(
    data = syd_te,
    aes(x = Quarter, y = Trips, group = 1),
    inherit.aes = FALSE, colour = "black", linewidth = 0.9
  ) +
  scale_colour_manual(
    values = c(ets = unname(ts_pal["navy"]), arima = unname(ts_pal["orange"])),
    labels = c(ets = "ETS trajectories", arima = "ARIMA trajectories")
  ) +
  guides(colour = guide_legend(override.aes = list(alpha = 0.9, linewidth = 1))) +
  labs(
    title = "Monte Carlo Simulated Sample Paths: Sydney Holiday Trips",
    subtitle = "100 Gaussian paths per model (black line = actual 2015-2017 observations)",
    x = "Quarter",
    y = "Holiday Trips (Thousands)",
    colour = "Model"
  )
Figure 1: One hundred simulated 3-year trajectories each from ETS and ARIMA fitted to pre-2015 Sydney Holiday trips, overlaid with actual test outcomes.

Horizon-Specific Empirical Summary & Fan Chart

A common mistake is pooling .sim values across all horizons into a single summary interval. Forecast uncertainty depends on the horizon \(h\) and seasonal phase, so empirical quantiles must always be computed by each (model, Quarter) pair (or across an equal-weight pool of trajectories at each Quarter for a simulated ensemble fan).

fan_ens <- sims_syd |>
  as_tibble() |>
  group_by(Quarter) |>
  summarise(
    mean   = mean(.sim),
    median = median(.sim),
    lo80   = quantile(.sim, 0.10),
    hi80   = quantile(.sim, 0.90),
    lo95   = quantile(.sim, 0.025),
    hi95   = quantile(.sim, 0.975)
  ) |>
  mutate(h = row_number())

fan_ens |>
  filter(h %in% c(1, 4, 8, 12)) |>
  select(h, Quarter, mean, median, lo80, hi80, lo95, hi95) |>
  fmt_tbl(digits = 1, caption = "Horizon-specific Monte Carlo ensemble intervals (200 pooled ETS + ARIMA paths)")
Horizon-specific Monte Carlo ensemble intervals (200 pooled ETS + ARIMA paths)
h Quarter mean median lo80 hi80 lo95 hi95
1 2015 Q1 584.2 584.4 461.5 707.9 391.0 764.3
4 2015 Q4 547.6 537.4 441.9 648.5 397.1 694.9
8 2016 Q4 546.9 545.7 440.8 669.0 394.5 717.8
12 2017 Q4 542.6 537.7 435.8 642.0 386.3 698.3
origin_syd <- slice_tail(syd_tr, n = 1)
fan_anchored <- bind_rows(
  origin_syd |> transmute(Quarter, median = Trips, lo80 = Trips, hi80 = Trips, lo95 = Trips, hi95 = Trips),
  as_tibble(fan_ens)
)
test_anchored <- bind_rows(as_tibble(origin_syd), as_tibble(syd_te))

ggplot() +
  geom_line(
    data = syd |> filter(Quarter >= yearquarter("2011 Q1"), Quarter < yearquarter("2015 Q1")),
    aes(x = Quarter, y = Trips), colour = ts_pal["slate"], linewidth = 0.7
  ) +
  geom_ribbon(data = fan_anchored, aes(x = Quarter, ymin = lo95, ymax = hi95, fill = "95% MC"), alpha = 0.25) +
  geom_ribbon(data = fan_anchored, aes(x = Quarter, ymin = lo80, ymax = hi80, fill = "80% MC"), alpha = 0.45) +
  geom_line(data = fan_anchored, aes(x = Quarter, y = median, colour = "MC Median"), linewidth = 0.9) +
  geom_line(data = test_anchored, aes(x = Quarter, y = Trips, colour = "Actual Test"), linewidth = 0.9) +
  scale_fill_manual(
    values = c("80% MC" = unname(ts_pal["navy"]), "95% MC" = unname(ts_pal["teal"])),
    breaks = c("80% MC", "95% MC")
  ) +
  scale_colour_manual(
    values = c("Actual Test" = unname(ts_pal["crimson"]), "MC Median" = unname(ts_pal["navy"])),
    breaks = c("Actual Test", "MC Median")
  ) +
  guides(colour = guide_legend(order = 1), fill = guide_legend(order = 2)) +
  labs(
    title = "Horizon-Specific Ensemble Fan Chart: Sydney Holiday Trips",
    subtitle = "Empirical 80% and 95% bands by quarter from 200 simulated ETS + ARIMA paths",
    x = "Quarter",
    y = "Holiday Trips (Thousands)",
    fill = "Interval",
    colour = "Series"
  )
Figure 2: Horizon-specific 80% and 95% Monte Carlo fan intervals from the pooled ETS + ARIMA trajectories for Sydney Holiday trips.

Practice Exercises

Exercise 1: Does Adding a Third Model Improve Melbourne Holiday CRPS?

Filter tourism to Region == "Melbourne", Purpose == "Holiday", holding out Quarter >= yearquarter("2015 Q1"). Fit ETS(Trips), ARIMA(Trips), and SNAIVE(Trips), then compare ens2 = (ets + arima) / 2 against ens3 = (ets + arima + snaive) / 3 by out-of-sample RMSE, MAE, and CRPS.

Solution

Here ARIMA is the strongest single model (CRPS = 41.6). Both ensembles sharply beat ETS (47.7) and SNAIVE (46.9), while adding SNAIVE slightly nudges CRPS from 43.9 to 44.1, illustrating that adding a weaker benchmark only helps when its errors are sufficiently uncorrelated with the existing models.

mel <- tourism |> filter(Region == "Melbourne", Purpose == "Holiday")
mel_tr <- mel |> filter(Quarter < yearquarter("2015 Q1"))
mel_te <- mel |> filter(Quarter >= yearquarter("2015 Q1"))

fit_mel <- mel_tr |>
  model(ets = ETS(Trips), arima = ARIMA(Trips), snaive = SNAIVE(Trips)) |>
  mutate(
    ens2 = (ets + arima) / 2,
    ens3 = (ets + arima + snaive) / 3
  )

fit_mel |>
  forecast(new_data = mel_te) |>
  accuracy(mel, measures = list(point_accuracy_measures, CRPS = CRPS)) |>
  select(.model, RMSE, MAE, CRPS) |>
  arrange(CRPS) |>
  fmt_tbl(digits = 2, caption = "Melbourne Holiday two-model vs. three-model ensemble comparison")
Melbourne Holiday two-model vs. three-model ensemble comparison
.model RMSE MAE CRPS
arima 75.21 52.66 41.64
ens2 80.49 53.69 43.86
ens3 81.13 55.36 44.07
snaive 84.34 58.94 46.94
ets 87.48 60.89 47.72

Exercise 2: Gaussian vs. Bootstrapped Monte Carlo Intervals

Using fit_syd |> select(ets) and set.seed(493), simulate times = 200 3-year trajectories twice: once with bootstrap = FALSE (Gaussian innovations) and once with bootstrap = TRUE (resampled training innovations). Compare the horizon-specific 95% interval widths at \(h = 1, 4, 8, 12\).

Solution

Bootstrapping resamples empirical innovation residuals without assuming normality, capturing skewness or heavier tails if present. On Sydney Holiday trips, the Gaussian and bootstrapped 95% widths track closely across all horizons, confirming that the ETS innovations are well approximated by a normal distribution.

set.seed(493)
sim_norm <- fit_syd |> select(ets) |> generate(h = "3 years", times = 200, bootstrap = FALSE) |>
  as_tibble() |> mutate(method = "Gaussian")

set.seed(493)
sim_boot <- fit_syd |> select(ets) |> generate(h = "3 years", times = 200, bootstrap = TRUE) |>
  as_tibble() |> mutate(method = "Bootstrap")

bind_rows(sim_norm, sim_boot) |>
  group_by(method, Quarter) |>
  summarise(width95 = quantile(.sim, 0.975) - quantile(.sim, 0.025)) |>
  group_by(method) |>
  mutate(h = row_number()) |>
  ungroup() |>
  filter(h %in% c(1, 4, 8, 12)) |>
  select(h, Quarter, method, width95) |>
  pivot_wider(names_from = method, values_from = width95) |>
  fmt_tbl(digits = 1, caption = "Comparison of 95% simulation interval widths: Gaussian vs. Bootstrap")
Comparison of 95% simulation interval widths: Gaussian vs. Bootstrap
h Quarter Bootstrap Gaussian
1 2015 Q1 263.0 352.6
4 2015 Q4 248.3 289.1
8 2016 Q4 289.0 339.0
12 2017 Q4 322.1 315.4

Key Takeaways

  • Combining forecasts across distinct families (ETS, ARIMA, SNAIVE) reduces error variance whenever individual forecast errors are less than perfectly correlated (\(\rho < 1\)).
  • Equal-weight ensembles provide a strong, low-variance baseline without requiring extra parameter estimation; be cautious when combining transformed models analytically in fable.
  • Monte Carlo simulation (generate() with set.seed()) produces flexible non-Gaussian or pooled-ensemble forecast distributions; map group = interaction(.model, .rep) when plotting paths.
  • Always summarize simulated trajectories by horizon (grouping by time index), never pooled across forecast steps.
Back to top