Time-Series Cross-Validation (Rolling/Expanding Window)

Econometrics
Introduced by
Christoph Bergmeir & José Benítez
Year
2012
Type
Forecast evaluation procedure
Family
Forecast evaluation

What does it do?

Time-series cross-validation is a resampling procedure designed for sequentially ordered data.

Instead of randomly partitioning observations, which would destroy temporal structure and can introduce data leakage, it advances a forecast origin one step at a time. At each origin the model is fitted on past data only, either all available history (expanding window) or the most recent w observations (rolling window), and is evaluated on the following out-of-sample period. Economists, financial analysts, and meteorologists use it whenever an operationally realistic estimate of predictive accuracy is required for a time-ordered process.

The intuition behind the method

Imagine replaying history: each month you train on everything you knew up to that point and then forecast the next month. You repeat this exercise across many months and average the errors. This mirrors how a practitioner would actually deploy the model — they never peek at tomorrow's data when fitting today's model. Rolling-window variants keep the training window fixed in length, so the model always sees the same amount of data, while expanding-window variants grow the window to exploit the full history available at each origin.

History

Rolling-origin evaluation, in which the forecast origin is advanced through the sample, is an established practice in forecasting. Bergmeir and Benítez (2012) examine the use of cross-validation for evaluating time-series predictors, and their paper is the reference for this page.

When to use it

Use time-series cross-validation when you need an accuracy estimate for temporally ordered data, such as macro-economic forecasting, stock return prediction, energy demand, or epidemiological surveillance, and when the aim is to mirror real use: forecasting forward from only the data available at each point in time. Check the assumptions of the chosen model before applying the scheme. If the model assumes a stationary series, difference or detrend the data first, because the validation procedure does not address that assumption itself. Shuffled k-fold cross-validation can leak information across time and is generally unsafe for forecast evaluation of dependent data. Bergmeir and Benítez (2012) discuss the use of cross-validation for time-series predictors, and that analysis should be consulted before using or ruling out k-fold in your case. For short series, the number of usable evaluation origins is small and the accuracy estimate is correspondingly unstable; in that setting, consider the bootstrap-inference approach listed among related methods and treat the results as provisional.

Limitations and considerations

  • Computationally expensive for large datasets or slow-to-fit models, since the model is re-estimated at every origin.
  • Early evaluation windows may be too short to fit complex models reliably, which can distort early-origin errors.
  • Consecutive forecast errors are serially correlated, so treating them as independent overstates statistical precision. Inference on RMSE differences needs a HAC-robust variance or a block bootstrap (see the diebold-mariano-test and bootstrap-inference pages).
  • Choice of minimum window size t₀ and window type (rolling vs. expanding) is subjective and can materially affect reported accuracy.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Strictly respects temporal ordering, eliminating look-ahead bias and data leakage.
  • Provides a realistic simulation of deployment conditions across many evaluation windows.
  • Model-agnostic: applicable to parametric models (ARIMA), machine-learning regressors, and neural networks alike.
  • Yields a sequence of per-origin errors that can be compared across models, for example with the Diebold-Mariano test. For horizons beyond one step, multi-step errors are serially correlated, so the test requires a valid long-run variance estimate for the loss differential.

Applications

  • Macro-economic forecasting: comparing ARIMA, VAR, and machine-learning models for GDP growth or inflation.
  • Financial risk management: rolling backtests of Value-at-Risk models over multi-year evaluation windows.
  • Energy demand forecasting: selecting among exponential smoothing variants for short-term electricity load.
  • Epidemiological surveillance: evaluating real-time influenza or COVID-19 incidence prediction models.
  • Retail inventory management: benchmarking seasonal demand forecasts at SKU level before production deployment.

How it works

How it works

1

A minimum initial training size t₀ has to be chosen. It should be large enough for the chosen model to be estimated reliably. It is a judgement call, it determines how many origins are evaluated, and it should be reported with the results. Forecast origins then advance one observation at a time (or one season at a time for seasonal data) from t₀ to T−h, where T is the total sample length and h is the forecast horizon.

Formula
\text{Select rolling origins } t_0, t_0+1, \ldots, T-h \text{ where } h \text{ is the forecast horizon}
2

At each origin t, the chosen model (e.g., ARIMA, exponential smoothing, or a machine-learning regressor) is re-estimated using only observations available at time t, and any tuning should be repeated inside that training window. In the expanding case the fit uses y₁ through yₜ, so no past observations are discarded. In the rolling case the fit uses only the most recent w observations, yₜ₋w+1 through yₜ, which keeps the training size constant and the computational cost per origin roughly constant.

Formula
\hat{f}_t = \mathcal{M}\!\left(\{y_1, \ldots, y_t\}\right) \text{ (expanding)}, \quad \hat{f}_t = \mathcal{M}\!\left(\{y_{t-w+1}, \ldots, y_t\}\right) \text{ (rolling)}, \quad t = t_0, \ldots, T-h
3

The refitted model produces an h-step-ahead point forecast ŷₜ₊ₕ|ₜ. For a univariate model this depends only on the fitted model and the horizon; if exogenous regressors are used, their values for the forecast period enter as well. The forecast error eₜ₊ₕ = yₜ₊ₕ − ŷₜ₊ₕ|ₜ is recorded. Because the actual value yₜ₊ₕ was never used in fitting, the error is genuinely out-of-sample.

Formula
\hat{y}_{t+h|t} = \hat{f}_t(h), \quad e_{t+h} = y_{t+h} - \hat{y}_{t+h|t}
4

All N recorded errors are aggregated into a scalar accuracy metric, most commonly RMSE, MAE (the mean of |e|), or MASE (MAE scaled by the in-sample MAE of a naive forecast). The resulting statistic summarises operational performance over the evaluation period. It should be interpreted relative to a naive benchmark (e.g., random walk or seasonal naive) evaluated on the same origins, and competing specifications should be compared on identical origins.

Formula
\mathrm{RMSE} = \sqrt{\frac{1}{N}\sum_{t=t_0}^{T-h} e_{t+h}^{2}}, \quad N = T - h - t_0 + 1

Common pitfalls

  • Using a single fixed train/test split yields one error sequence from a small number of forecasts, so the accuracy estimate is noisy and can be unrepresentative. Rolling origins provide many more out-of-sample errors for comparison.
  • Tuning hyper-parameters once on the full sample, rather than inside each origin's training window, lets information from future observations shape the forecasts that are then scored, so the error estimate is optimistic.
  • Aggregating errors across horizons (e.g., mixing h=1 and h=12 errors into a single RMSE) conflates structurally different error distributions.
  • Ignoring serial correlation among evaluation errors and reporting naive standard errors of the mean RMSE; use a HAC-robust variance or block bootstrap instead.

Frequently asked questions

What is the difference between rolling-window and expanding-window cross-validation?

In the rolling (fixed-window) variant the training set always contains the most recent w observations; older data are dropped as the origin advances. In the expanding variant the training set grows monotonically — every historical observation is retained. The expanding window is generally preferred when data are scarce or when long-run patterns matter; rolling windows are preferred when structural breaks make old data misleading or when computational budget is tight.

Can I use time-series cross-validation for multi-step forecasts?

Yes. At each origin you generate forecasts for horizons h = 1, 2, …, H and record separate error sequences for each horizon. Accuracy is then reported per horizon. Be careful not to pool errors across horizons into a single metric without weighting, because short-horizon and long-horizon errors have very different magnitudes and volatility structures.

How many evaluation windows do I need for reliable accuracy estimates?

This page does not give a validated minimum number of origins. Report the number of origins used, and treat accuracy estimates from a small number of origins as uncertain, with wide intervals. For seasonal data, evaluating over several full seasonal cycles helps ensure that the seasonal pattern is represented in the evaluation period.

Related methods

Sources

  1. Bergmeir, C., & Benítez, J. M. (2012). On the use of cross-validation for time series predictor evaluation. Information Sciences, 191, 192–213.

    Open DOI reference