Method · Statistics Library

Forecast backtest (rolling-origin)

Rolling-origin backtesting repeatedly fits a forecasting model on a training window, scores its out-of-sample error at several horizons against what actually happened, and compares it to naive and seasonal-naive baselines to check whether the model earns its complexity.

Topic indexA reference reading outside the guided chapter sequence

Understand the idea

In-sample fit statistics like SSE describe how well a model explains data it has already been shown, a bit like grading yourself on an exam you've already seen the answer key for; AIC adds a penalty for complexity but is still computed from that same data. This tool instead asks the honest question: fit the model on the past, forecast a few steps into a future it has NOT seen, then check what actually happened. Slide the training window forward one step, repeat, and average the errors across every one of these 'origins.'

Two model-free yardsticks are scored on every fold alongside your model: NAIVE (tomorrow looks like today) and SEASONAL NAIVE (this period looks like it did one full cycle ago). These sound almost too simple to bother with, and that is exactly the point: a model that cannot beat them is not earning the extra complexity it's asking you to trust.

MASE (scaled error) divides the model's error by how much the series typically changes from one period to the next (or from one season to the next), measured over the whole series. A value below 1 means the model's errors are smaller than that typical change. That is not the same as beating the naive forecast on the same test periods; to know that, compare the model's error with the naive forecast's error on the same folds, which the card shows.

A backtest, also called rolling-origin cross-validation or walk-forward validation, repeatedly fits the model on the past and forecasts the next stretch, to measure out-of-sample forecast accuracy honestly.

Practitioner explanation

KernelStats runs true rolling-origin (walk-forward) validation: fit the chosen candidate on a training window, forecast horizons h = 1..H, score against the actual held-out values, roll the origin forward by the step size, and repeat across K folds, with either an EXPANDING window (all history so far; use when older data stays relevant) or a SLIDING window of fixed size (use when the process drifts and old data goes stale). Candidates include ARIMA and Holt-Winters exponential smoothing (with the same order/trend/seasonal options as their standalone functions), scored alongside the naive and seasonal-naive baselines on identical folds. Like the three forecasting cards, it takes an optional period column (a date, 2023-01, Jan 2023, 2023Q1 or a year) that is used only to check the spacing and label the calendar; it never changes a number.

Per horizon the card reports MAE, RMSE, MAPE when actual values permit it, and scaled error labeled MASE. Its denominator is computed once over the full series, not each training window: average absolute one-step change, or seasonal change for seasonal-naive or Holt-Winters candidates when the seasonal scale is available. All methods within that run share the scale. It includes later observations, so it is not a training-only MASE estimate. Candidate-dependent scales also mean that differently scaled runs cannot be compared directly. Use the same-fold baseline errors to judge whether the candidate improves forecast accuracy.

Two cautions this function states directly: the comparison assumes the process generating the training folds is still representative of the test folds (a structural break inflates the error for every method, baselines included, so a bad score is not automatically the candidate's fault alone), and MASE is undefined on a constant series, where the naive one-step scale collapses to zero.

When to use it

Consider it when

You have a forecasting model (or are choosing between several) and want an honest, out-of-sample answer to how good its forecasts really are, instead of trusting in-sample fit statistics like AIC or SSE.

Use caution when

The rows are not time-ordered (an ordinary regression or classification problem with exchangeable rows should use the cross-validation function's k-fold cross-validation instead), the series is too short to support even one full training window plus the forecast horizon, or you have not yet fit any candidate model and just want a first forecast (fit with ARIMA or exponential smoothing first, then come back here to validate it).

Formulas and symbols

Mean Absolute Error (per horizon)

MAE(h)=1K∑k=1K∣ytk+h−y^tk+h∣\text{MAE}(h) = \frac{1}{K}\sum_{k=1}^{K} \left| y_{t_k+h} - \hat{y}_{t_k+h} \right|

K rolling-origin folds, t_k the origin of fold k.

Root Mean Square Error (per horizon)

RMSE(h)=1K∑k=1K(ytk+h−y^tk+h)2\text{RMSE}(h) = \sqrt{\frac{1}{K}\sum_{k=1}^{K} \left( y_{t_k+h} - \hat{y}_{t_k+h} \right)^2}

Penalizes large misses more than MAE; RMSE much greater than MAE flags a few unusually bad folds.

Mean Absolute Scaled Error (per horizon)

MASE(h)=MAE(h)Dm,Dm=1n−m∑t=m+1n∣yt−yt−m∣\mathrm{MASE}(h)=\frac{\mathrm{MAE}(h)}{D_m},\qquad D_m=\frac{1}{n-m}\sum_{t=m+1}^n|y_t-y_{t-m}|

This card computes D_m once over the full series of n observations. Use m=1 for the one-step scale; for seasonal-naive and Holt-Winters candidates with an available seasonal scale use the selected seasonal period. A score below one is below this reference scale, not proof of beating the held-out naive forecast. Compare candidate and baselines on identical folds and a common scale; differently scaled runs are not directly comparable. A zero scale gives an undefined scaled error.

Assumptions and checks

  • Stationarity. A structural break between the training folds and the test folds (a regime change, a level shift, a broken seasonal cycle) inflates the reported error for every method scored, baselines included, so a poor score does not automatically indict the candidate model alone.

    In KernelStats: Not checked by KernelStats: no structural-break or regime-change test runs before or during the backtest; only the resulting fold errors are reported, and a sudden jump in per-fold error across the series is the practical clue to look for.

Alternatives

  • Cross-Validated Model Comparison. The modeling task is ordinary regression or classification with exchangeable rows, not sequential time series: use k-fold cross-validation instead of rolling-origin backtesting.
  • ARIMA Forecast. You just want to fit and forecast a model, not evaluate its historical out-of-sample accuracy yet.

Worked example

Scenario

36 months of retail sales, backtested with ARIMA(1,1,1) using an expanding window, horizons 1 through 4, seasonal period 12.

Result

Averaged over the rolling folds, the ARIMA candidate scores MASE(1) = 0.81 and MASE(4) = 0.97, while the seasonal-naive baseline scores MASE(1) = 1.05 and MASE(4) = 0.93 over the identical folds.

Interpretation

On the same folds and scale, the illustrated ARIMA error is smaller than seasonal naive at horizon one (0.81 versus 1.05), while seasonal naive is smaller at horizon four (0.93 versus 0.97). These numbers alone say nothing about the unreported nonseasonal-naive error. A score below one is not itself a same-fold baseline comparison.

Common misconceptions

Misconception

My model has a lower AIC, so it must forecast better.

Correction

AIC is a model-based criterion related to expected predictive fit under its assumptions; a lower value does not guarantee smaller realized future forecast errors. Compare candidate and baseline errors on identical held-out folds, using a common scale for scaled errors.

Read more: Misconception: a model's training-set accuracy is its real-world performance

Misconception

A more complex model always beats a naive guess.

Correction

Often false, especially at short horizons or on noisy series: sophisticated models frequently fail to beat a seasonal-naive baseline once scored honestly out-of-sample, which is precisely the comparison this function exists to surface rather than assume away.

References

  1. Another look at measures of forecast accuracy, Hyndman, R. J. and Koehler, A. B. (2006), International Journal of Forecasting, 22(4), 679-688.
  2. Out-of-sample tests of forecasting accuracy: An analysis and review, Tashman, L. J. (2000), International Journal of Forecasting, 16(4), 437-450.
  3. Forecasting: Principles and Practice: forecast accuracy and scaled errors, Hyndman, R. J. and Athanasopoulos, G..