Tutorials › Exam SRM - Statistics for Risk Modeling › Blocked Validation Versus Random Folds

Exam SRM · Time-Series Forecasting Cases · Tutorial 895 of 926

Blocked Validation Versus Random Folds

Learn to choose validation folds that match the forecasting task, quantify the effect of autocorrelation, and recognize when random-fold errors understate future forecast error.

Advanced 12 min read

What You'll Learn

  • Distinguish forecasting future observations from interpolating missing observations within a series
  • Explain how random folds can place future, correlated observations in the training set
  • Derive and compare AR(1) forecast and two-sided interpolation error variances
  • Calculate RMSE from random-fold and chronological validation errors
  • Design blocked validation folds that preserve time order
  • Identify when random folds are reasonable and when they misrepresent the intended prediction task

Why the Validation Split Must Match the Forecasting Task

A validation score estimates performance on a particular prediction task. For a time series, that task is often to forecast future observations using information available at the forecast origin. A randomly shuffled split can change the task: a validation observation may have nearby observations on both sides in the training data, including observations that would not yet exist when a real forecast is made.

This distinction matters when observations are autocorrelated. If adjacent values tend to be similar, a training value just after a held-out time can reveal information about that held-out value. Random folds can then make predictions look more accurate than forecasts made strictly forward in time. This is a risk, not a guarantee: the size and direction of the difference depend on the series, model, and evaluation design.

Definition: Blocked validation evaluates predictions on one or more contiguous time blocks while ensuring that the training information for each forecast does not include observations from after its forecast origin. Random-fold validation assigns individual observations or rows to folds without preserving chronological order. For a forecasting task, random-fold validation may give the model access to future observations relative to a validation time.

The target must be clear before choosing a split. Forecasting next month’s value from data available this month is not the same task as estimating a missing value inside a completed historical series. The latter is an interpolation task, for which observations after the missing time may legitimately be available. Validation should reproduce the information set and time direction of the intended use.

How Autocorrelation Makes Random Folds Optimistic

Consider a stationary Gaussian AR(1) process, centered to have mean zero:

$$ Y_t=\rho Y_{t-1}+\varepsilon_t,\qquad |\rho|<1,\qquad \varepsilon_t\sim N(0,\sigma_\varepsilon^2), $$

where the innovations are independent over time. Assume the parameters are known, so parameter-estimation uncertainty is not part of this comparison. If the task is to forecast \(Y_t\) using observations only through time \(t-1\), the one-step forecast is \(\rho Y_{t-1}\). Its forecast error is \(\varepsilon_t\), so its mean squared error is \(\sigma_\varepsilon^2\).

In contrast, suppose a held-out \(Y_t\) has both neighbors \(Y_{t-1}\) and \(Y_{t+1}\) available. Under this Gaussian model, the conditional distribution of \(Y_t\) given both neighbors has variance \(\sigma_\varepsilon^2/(1+\rho^2)\). The next derivation shows why.

Derivation: Conditioning on Both Neighbors

Given \(Y_{t-1}=a\), the density contribution involving \(Y_t=y\) from the transition into time \(t\) is proportional to \(\exp[-(y-\rho a)^2/(2\sigma_\varepsilon^2)]\). Given \(Y_{t+1}=b\), the transition out of time \(t\) contributes \(\exp[-(b-\rho y)^2/(2\sigma_\varepsilon^2)]\). Multiplying these terms gives the conditional density as a function of \(y\):

$$ p(y\mid a,b)\ \propto\ \exp\left\{-\frac{(y-\rho a)^2+(b-\rho y)^2}{2\sigma_\varepsilon^2}\right\}. $$

To identify its variance, collect the terms involving \(y\) in the numerator:

$$ (y-\rho a)^2+(b-\rho y)^2 =(1+\rho^2)y^2-2\rho(a+b)y+\rho^2a^2+b^2. $$

Completing the square in \(y\) gives a quadratic term \((1+\rho^2)\left(y-\frac{\rho(a+b)}{1+\rho^2}\right)^2\), plus terms that do not depend on \(y\). Comparing the resulting exponential with a normal density shows that

$$ E[Y_t\mid Y_{t-1}=a,Y_{t+1}=b] =\frac{\rho(a+b)}{1+\rho^2},\qquad \operatorname{Var}(Y_t\mid Y_{t-1},Y_{t+1}) =\frac{\sigma_\varepsilon^2}{1+\rho^2}. $$

Because \(1+\rho^2>1\) whenever \(\rho\ne0\), the conditional variance using both neighbors is smaller than the one-step forecast error variance. Random folds can make this two-sided information available for some held-out times. A forecasting evaluation should not use that advantage when the future neighbor would be unknown at the forecast origin.

Worked Example: Quantifying the Two-Sided Information Advantage

A hypothetical centered monthly series follows a known stationary Gaussian AR(1) model with \(\rho=0.8\) and innovation standard deviation \(\sigma_\varepsilon=10\). Compare the one-step forecasting error variance with the conditional variance for a held-out month when both neighboring months are available. Then calculate the corresponding RMSE values.

Method. Use the one-sided AR(1) forecast error variance for forecasting and the two-sided conditional variance derived above for interpolation. This comparison isolates the information advantage; it does not include parameter-estimation uncertainty.

One-sided forecast. The innovation variance is \(10^2=100\). Therefore, the one-step forecast error variance is \(100\), and the forecast RMSE is \(\sqrt{100}=10\).

Two-sided conditional estimate. First, \(\rho^2=0.8^2=0.64\), so \(1+\rho^2=1.64\). The conditional variance is \(100/1.64=60.9756\) to four decimal places. Its RMSE is \(\sqrt{60.9756}=7.8087\), to four decimal places.

Check. The two-sided RMSE, \(7.8087\), is less than the one-sided forecast RMSE, \(10\), as expected because the interpolation estimate conditions on additional information. Treating the smaller value as a future-forecast score would be misleading if the future neighbor is unavailable at forecast time.

Building a Chronological Validation Design

A blocked design keeps the evaluation period later than the data used to fit the corresponding forecast. One simple design reserves the final contiguous portion of a series as validation data. Another uses several chronological forecast origins: fit through an origin, predict a later block, then move the origin forward. The earlier material on rolling-origin evaluation covers that repeated-origin setup; the key point here is that time order is preserved, unlike in randomly shuffled folds.

When scoring multiple forecast errors, pool the squared errors before taking the square root if the desired summary is overall RMSE. For errors \(e_1,\ldots,e_n\), RMSE is \(\sqrt{\sum_{j=1}^n e_j^2/n}\). The training and validation periods, forecast horizon, and scoring calculation should be reported clearly. If different folds have different sizes, averaging their RMSEs gives each fold equal weight, which is generally not the same as pooling all squared errors.

1
Specify the prediction target.
State which time or horizon is being forecast and what information would be available then.
2
Set chronological cutoffs.
Place each validation block after the observations used to fit its forecast. Do not shuffle individual times across those sets.
3
Calculate errors and summarize them.
For each validation prediction, subtract the forecast from the observed value. Pool squared errors for an overall RMSE, or report separate block scores when performance over time is important.

Worked Example: Comparing Random-Fold and Blocked RMSE

A hypothetical monthly forecasting study has four validation observations in each of two designs. In the randomly shuffled design, the forecast errors are \(1,-2,1,-2\). In the chronological blocked design, the errors for the later four months are \(4,-5,4,-6\). Calculate both RMSE values and interpret the comparison.

Method. For each design, square every error, find the mean squared error, and take its square root. The errors are supplied as the outputs of the two validation procedures; the calculation compares their scores but does not establish that every random split must be more optimistic.

Random-fold score. The squared errors are \(1^2=1\), \((-2)^2=4\), \(1^2=1\), and \((-2)^2=4\). Their sum is \(1+4+1+4=10\), and their mean is \(10/4=2.5\). Thus the RMSE is \(\sqrt{2.5}=1.5811\), rounded to four decimals.

Blocked score. The squared errors are \(4^2=16\), \((-5)^2=25\), \(4^2=16\), and \((-6)^2=36\). Their sum is \(16+25+16+36=93\), and their mean is \(93/4=23.25\). Thus the RMSE is \(\sqrt{23.25}=4.8218\), rounded to four decimals.

Interpretation and check. The random-fold score is much smaller than the later-block score. If the random-fold training sets contained observations from near or after their validation times, autocorrelation could have made those predictions easier than genuine future forecasts. The arithmetic checks: the blocked errors are larger in magnitude overall, so their RMSE is larger.

When Random Folds Are Appropriate—and When They Are Not

Random folds are not inherently invalid. They can be appropriate when observations are independent and exchangeable for the prediction task, or when the goal is to predict a randomly omitted point within a completed series and both past and future information are legitimately available. But a time index alone does not make a dataset safe for random folds: dependence between observations, the forecast horizon, and the information available at prediction time all matter.

For a future-forecasting task, random folds can understate error in several related ways. A held-out value may have a nearby future value in the training set; adjacent rows in a lagged dataset may share observations; and the validation set may mix easy interior periods with the genuinely difficult end-of-series forecast period. The resulting score estimates performance under that shuffled arrangement, not necessarily performance at a future forecast origin.

Worked Example: Computing a Pooled Score Across Chronological Blocks

A hypothetical model is evaluated on three successive two-month validation blocks. Its forecast errors, in chronological order within each block, are: Block 1, \(-2,2\); Block 2, \(-1,3\); Block 3, \(-4,0\). Find the overall pooled RMSE and compare it with the unweighted mean of the three block RMSEs.

Method. Preserve the chronological blocks, square all six errors, and pool those squares for the overall RMSE. Then calculate each block RMSE separately to illustrate the effect of averaging folds rather than observations.

Pooled RMSE. The six squared errors are \(4,4,1,9,16,0\). Their sum is \(34\), so the mean squared error is \(34/6=5.6667\) to four decimals. The pooled RMSE is \(\sqrt{34/6}=2.3805\), rounded to four decimals.

Block RMSEs. Block 1 has mean squared error \((4+4)/2=4\), so its RMSE is \(2\). Block 2 has mean squared error \((1+9)/2=5\), so its RMSE is \(\sqrt{5}=2.2361\). Block 3 has mean squared error \((16+0)/2=8\), so its RMSE is \(\sqrt{8}=2.8284\). Their unweighted mean is \((2+2.2361+2.8284)/3=2.3548\), rounded to four decimals.

Check. The pooled RMSE, \(2.3805\), differs from the mean block RMSE, \(2.3548\). Each block has the same two observations here, but averaging square roots is still not the same operation as taking the square root of the pooled mean squared error.

Common Exam Trap

A frequent mistake is to regard randomly shuffled cross-validation as a neutral substitute for chronological validation simply because every observation is used for both training and validation across folds. That argument ignores what information is available at the forecast origin. Randomly assigning times can put later, correlated observations into training for a held-out earlier time. A low score may then measure interpolation or a mixed-time prediction task rather than future forecasting.

The correction is to state the prediction target first, then enforce its information boundary in the split. For a forecast of time \(t\) using information available through \(t-1\), training observations after \(t-1\) must not help produce that validation forecast. Conversely, if the actual task is to fill a historical gap using data on both sides, a two-sided method may be suitable—but it should be described as interpolation rather than future forecasting.

Key takeaway: Validation estimates performance only for the prediction task its split represents. When autocorrelation is present, a shuffled split can let nearby future observations make held-out points easier to predict. Use chronological blocks for future forecasting, and interpret random-fold scores only when their information pattern matches the intended task.

Check Your Understanding

For each problem, decide what information the validation design permits and check the calculation.

  1. A stationary Gaussian AR(1) series has \(\rho=0.5\) and innovation standard deviation \(4\). Find the one-step forecast error variance and the conditional variance of a held-out point when both neighbors are observed. (Answer: forecast variance \(16\); two-sided conditional variance \(16/1.25=12.8\).)
  2. A random-fold validation produces errors \(2,0,-2,0\), while a later chronological block produces errors \(3,-4,3,-4\). Calculate both RMSEs. (Answer: random-fold RMSE \(\sqrt{2}=1.4142\); blocked RMSE \(\sqrt{12.5}=3.5355\), to four decimals.)
  3. A forecaster has 20 monthly observations and wants to assess predictions for the final four months using only earlier data. Specify a simple blocked split. (Answer: train using months 1–16 and validate on months 17–20, with each forecast based only on information available before its target.)
  4. A researcher wants to estimate a missing value in the middle of a completed series and will have observations both before and after the gap at implementation. Is a random split automatically unsuitable? (Answer: no; two-sided information may match the interpolation task, but it would not estimate a strictly future-forecasting error.)
  5. For a Gaussian AR(1) model with \(\rho=0.9\) and innovation variance \(\sigma_\varepsilon^2\), express the ratio of the two-sided conditional variance to the one-step forecast variance. (Answer: \(1/(1+0.9^2)=1/1.81\approx0.5525\).)
Clinical Biostats