Library · Validation

The block bootstrap for time series

Resampling single observations breaks the dependence between neighbours in time. The block bootstrap resamples stretches of consecutive observations instead, and gives confidence intervals that account for autocorrelation.

By , published

Definition

In the moving block bootstrap of Künsch, the series is cut into overlapping blocks of length b; blocks are drawn with replacement and joined end to end until the original length is reached. The statistic is recomputed on each resampled series. The stationary bootstrap of Politis and Romano draws blocks of random length, which keeps the resampled series stationary.

Within a block the order of the observations, and so their dependence, is preserved. The block length must be long enough to contain that dependence and short enough to leave many blocks.

Worked example

Series of 300 points are generated with a strong positive autocorrelation and a true mean of zero. For each of 400 series, a 90 % interval for the mean is built with the ordinary bootstrap and with blocks of 20. We count how often each interval contains the true mean.

import numpy as np

rng = np.random.default_rng(11)
n, phi, b, B = 300, 0.7, 20, 400

def series():
    e = rng.normal(size=n + 50)
    x = np.zeros(n + 50)
    for t in range(1, n + 50):
        x[t] = phi * x[t - 1] + e[t]
    return x[50:]

def interval(x, block):
    if block == 1:
        idx = rng.integers(0, n, (B, n))
    else:
        starts = rng.integers(0, n - block + 1, (B, n // block))
        idx = (starts[:, :, None] + np.arange(block)).reshape(B, -1)
    means = x[idx].mean(axis=1)
    return np.percentile(means, [5, 95])

hits = {1: 0, b: 0}
for _ in range(400):
    x = series()
    for block in hits:
        lo, hi = interval(x, block)
        hits[block] += lo <= 0 <= hi
print(f"ordinary bootstrap:      90 % interval contains the true mean in {hits[1] / 400:.0%} of series")
print(f"block bootstrap (b = {b}): 90 % interval contains the true mean in {hits[b] / 400:.0%} of series")

Output, produced by running the code above when this page was built:

ordinary bootstrap:      90 % interval contains the true mean in 46% of series
block bootstrap (b = 20): 90 % interval contains the true mean in 84% of series

The ordinary bootstrap produces intervals that miss the true mean far more often than one time in ten. The block bootstrap is much closer to the nominal level, without reaching it exactly.

Where it misleads

  • The block length is a choice. Too short and the dependence is cut; too long and there are too few distinct blocks. Automatic rules exist, and the result should be checked for a few lengths.
  • Coverage stays somewhat below the nominal level on short series with strong dependence, as in the example. The method reduces the problem, it does not remove it.
  • A trend or a seasonal pattern must be removed, or modelled, before resampling. Blocks of a trending series do not look alike.
  • For a panel of many series, resampling whole series, or whole dates, is often the relevant unit, not blocks within one series.

In our work

Every score we report has an interval, and the resampling unit is chosen from the dependence in the data: blocks of time for one series, whole series for a catalogue, as in the paired intervals of our demand comparisons.

References

  1. Künsch, H. R. (1989). The jackknife and the bootstrap for general stationary observations. Annals of Statistics, 17(3), 1217-1241. doi:10.1214/aos/1176347265
  2. Politis, D. N., Romano, J. P. (1994). The stationary bootstrap. Journal of the American Statistical Association, 89(428), 1303-1313. doi:10.1080/01621459.1994.10476870
  3. Efron, B., Tibshirani, R. J. (1993). An introduction to the bootstrap. Chapman and Hall, New York. doi:10.1201/9780429246593

Have a question like this one on your own data? Tell us what you need in a few lines.

Send us the brief

Related pages

  • Paired comparison of two modelsTwo models tested on the same rows share most of their luck. Comparing their two confidence intervals ignores that. The interval of the difference, computed on the same resampled rows, is much narrower.
  • Purged k-fold cross-validation with an embargoWhen a label is built from several future periods, neighbouring observations share part of their label. With such overlapping labels, purging removes from training every observation that overlaps the test fold; the embargo adds a gap after it.
  • Diebold-Mariano testTwo forecasts never have the same error. The Diebold-Mariano test, the standard tool for forecast comparison, says whether the gap between them is larger than what chance produces on a window of that length, using the paired differences of their losses.
All library pages