Skip to content
LeetQuant
QR03 Statistical Inference and Estimation

QR03 · Statistical Inference and Estimation · Lesson 3 of 4

The Bootstrap

Resample the data to get standard errors and intervals without formulas, know exactly when that fails (heavy tails, maxima, dependence), and use the block bootstrap for time series.

17 min

The idea: plug in the empirical distribution

The sampling distribution of an estimator θ^=T(X1,…,Xn)\hat\theta = T(X_1, \dots, X_n) depends on the unknown distribution FF of the data. If we knew FF we could simulate: draw many samples of size nn from FF, compute TT on each, and read off the spread. The bootstrap replaces the unknown FF by the empirical distribution F^n\hat F_n, which puts mass 1/n1/n on each observed point. Drawing from F^n\hat F_n is drawing with replacement from the data.

The nonparametric bootstrap:

  1. For b=1,…,Bb = 1, \dots, B: draw X1∗,…,Xn∗X_1^*, \dots, X_n^* with replacement from the data and compute θ^b∗=T(X∗)\hat\theta^*_b = T(X^*).
  2. Standard error: the standard deviation of θ^1∗,…,θ^B∗\hat\theta^*_1, \dots, \hat\theta^*_B.
  3. Percentile interval: the α/2\alpha/2 and 1−α/21 - \alpha/2 quantiles of the θ^b∗\hat\theta^*_b.

Its appeal is that TT can be anything: a median, a Sharpe ratio, a correlation, the maximum drawdown, the coefficient from a whole fitting pipeline. No derivative, no delta method, no Fisher information.

Two separate errors are involved. The Monte Carlo error comes from finite BB and can be made as small as you like: B≈200B \approx 200–10001000 is enough for a standard error, B≥2000B \ge 2000 for the tails of an interval. The bootstrap error comes from F^n≠F\hat F_n \ne F and does not shrink with BB; it is what limits the method, and it is what the failure cases are about.

Intervals

  • Percentile: [qα/2∗,  q1−α/2∗][q^*_{\alpha/2},\; q^*_{1-\alpha/2}]. Simple and invariant to monotone transformations, but it can be biased when θ^\hat\theta is biased or its spread depends on θ\theta.
  • Basic (reverse percentile): [2θ^−q1−α/2∗,  2θ^−qα/2∗][2\hat\theta - q^*_{1-\alpha/2},\; 2\hat\theta - q^*_{\alpha/2}]. It assumes θ^−θ\hat\theta - \theta behaves like θ^∗−θ^\hat\theta^* - \hat\theta, and flips the asymmetry.
  • Bootstrap-tt: bootstrap the studentised statistic (θ^∗−θ^)/SE⁡∗(\hat\theta^* - \hat\theta)/\operatorname{SE}^*. More accurate (second-order correct) when a standard error is available for each resample.
  • BCa: percentile with bias and skewness corrections; the usual default in statistical software.

A useful fact for interviews: a given observation is absent from a resample with probability (1−1/n)n→e−1≈0.368(1 - 1/n)^n \to e^{-1} \approx 0.368, so each resample contains about 63.2% of the distinct original points. That is also where the out-of-bag fraction in random forests comes from.

Worked example

the exact bootstrap of a mean

The data are {1,2,6}\{1, 2, 6\}. Find the exact bootstrap distribution of the sample mean, its bootstrap standard error, and compare with the usual s/ns/\sqrt n.

Show solution

There are 33=273^3 = 27 equally likely ordered resamples (10 distinct multisets). The resample mean is Xˉ∗=13(X1∗+X2∗+X3∗)\bar X^* = \tfrac13(X_1^* + X_2^* + X_3^*) with Xj∗X_j^* i.i.d. uniform on {1,2,6}\{1, 2, 6\}, so

Var⁡(Xˉ∗)=σ^2n,σ^2=(1−3)2+(2−3)2+(6−3)23=143.\operatorname{Var}(\bar X^*) = \frac{\hat\sigma^2}{n}, \qquad \hat\sigma^2 = \frac{(1-3)^2 + (2-3)^2 + (6-3)^2}{3} = \frac{14}{3} .

So Var⁡(Xˉ∗)=14/9\operatorname{Var}(\bar X^*) = 14/9 and the bootstrap SE is 14/9≈1.247\sqrt{14/9} \approx 1.247. Enumerating all 27 resamples confirms this.

The usual estimate uses s2=14/2=7s^2 = 14/2 = 7: s/3=7/3≈1.528s/\sqrt 3 = \sqrt{7/3} \approx 1.528. The bootstrap uses the plug-in variance (divisor nn), so its SE is smaller by (n−1)/n=2/3\sqrt{(n-1)/n} = \sqrt{2/3}. Negligible for n=500n = 500, an 18% understatement for n=3n = 3: the bootstrap is a large-sample method.

The distribution is also right-skewed: it is centred at 3 but runs from 1 to 6, and its upper tail (means of 4.334.33, 4.674.67 and 66) comes entirely from resamples that contain the 6. A percentile interval inherits that skew, which is appropriate if the population is skewed and misleading if the skew is an accident of three points.

When the bootstrap fails

The bootstrap works when θ^\hat\theta is a smooth function of averages and the data are i.i.d. with enough moments. It fails, or needs modification, in four standard situations.

1. Extremes and other non-smooth statistics. For Uniform(0,θ0, \theta) the MLE is the sample maximum. A resample contains the sample maximum with probability 1−(1−1/n)n≈0.6321 - (1 - 1/n)^n \approx 0.632, so the bootstrap distribution of max⁡X∗\max X^* has a 63% point mass at max⁡X\max X, while the true sampling distribution of n(θ−max⁡X)/θn(\theta - \max X)/\theta is continuous (approximately exponential). The bootstrap cannot see values beyond the largest observation. The same goes for extreme quantiles, VaR at very high confidence, and the maximum drawdown of a short series.

2. Heavy tails. For the mean of data with infinite variance (tail index below 2) the bootstrap is inconsistent. With finite but large kurtosis it is consistent but slow: the bootstrap SE inherits the noise of the sample variance, which is dominated by the few largest observations, so intervals undercover in samples of realistic size. Financial returns sit in this regime; the bootstrap SE of a Sharpe ratio from two years of daily data can be badly off.

3. Parameters at a boundary. If the true value is on the edge of the parameter space (a variance component of zero, a constrained weight at its limit) the bootstrap distribution is wrong. The mm-out-of-nn bootstrap (resample m≪nm \ll n points) repairs this and the extremes case at the price of choosing mm.

4. Dependence. Resampling individual observations destroys the serial dependence. For a positively autocorrelated series the variance of the mean is larger than σ2/n\sigma^2/n; for an AR(1) with coefficient ϕ\phi the long-run variance is σ2(1+ϕ)/(1−ϕ)\sigma^2(1 + \phi)/(1 - \phi), three times σ2\sigma^2 when ϕ=0.5\phi = 0.5. An i.i.d. bootstrap reports σ2/n\sigma^2/n and is over-confident.

The block bootstrap

For time series, resample blocks of consecutive observations and glue them together. Within a block the dependence is preserved; between blocks it is broken, so blocks must be long relative to the correlation length. The moving-block bootstrap draws blocks of fixed length ℓ\ell starting at random positions; the stationary bootstrap (Politis–Romano) draws geometric block lengths with mean ℓ\ell so the resampled series is itself stationary; the circular version wraps around the end. A standard rule of thumb is ℓ∝n1/3\ell \propto n^{1/3} for variance estimation, tuned to the persistence of the data.

Worked example

i.i.d. versus block bootstrap on an AR(1)

Simulate 500 points of an AR(1) xt=0.5 xt−1+εtx_t = 0.5\,x_{t-1} + \varepsilon_t with εt∼N(0,1)\varepsilon_t \sim N(0, 1). Estimate the standard error of the sample mean with an i.i.d. bootstrap and with moving-block bootstraps, and compare with the true asymptotic value.

Show solution

The stationary variance is σx2=1/(1−ϕ2)=4/3\sigma_x^2 = 1/(1 - \phi^2) = 4/3 and the long-run variance is σε2/(1−ϕ)2=4\sigma_\varepsilon^2/(1-\phi)^2 = 4, so the true SE of the mean is 4/500≈0.0894\sqrt{4/500} \approx 0.0894. An i.i.d. bootstrap can only see σx2\sigma_x^2 and should give about (4/3)/500≈0.052\sqrt{(4/3)/500} \approx 0.052.

import random
import statistics as st

random.seed(7)
phi, n = 0.5, 500
x, prev = [], 0.0
for _ in range(n + 100):  # AR(1) with 100 burn-in steps
    prev = phi * prev + random.gauss(0, 1)
    x.append(prev)
x = x[100:]


def boot_se(data, block, reps=2000):
    m = len(data)
    starts = range(m - block + 1)
    means = []
    for _ in range(reps):
        sample = []
        while len(sample) < m:  # glue random blocks of consecutive points
            s = random.choice(starts)
            sample.extend(data[s : s + block])
        means.append(sum(sample[:m]) / m)
    return st.stdev(means)


print(f"iid bootstrap SE   {boot_se(x, 1):.4f}")
print(f"block (length 10)  {boot_se(x, 10):.4f}")
print(f"block (length 25)  {boot_se(x, 25):.4f}")
print(f"true asymptotic SE {(1 / (1 - phi)) / n ** 0.5:.4f}")
# iid bootstrap SE   0.0538
# block (length 10)  0.0932
# block (length 25)  0.1104
# true asymptotic SE 0.0894

The i.i.d. bootstrap (block length 1) understates the SE by about 40%, as predicted: it would make a mean look 3≈1.7\sqrt 3 \approx 1.7 times more significant than it is. Blocks of length 10 recover the right order of magnitude. The length-25 answer overshoots, which shows the trade-off: longer blocks reduce bias from cutting dependence but leave fewer effectively independent blocks (20 here), so the estimate gets noisier. For a single series of 500 points, either estimate is itself uncertain by 10–20%.

Knowledge check

You bootstrap a dataset of 100 observations. What is the probability that a particular observation does not appear in a given resample?

Knowledge check

You use the bootstrap to put an interval on the upper endpoint of a Uniform(0, θ) distribution, estimated by the sample maximum of 200 points. Why is the result unreliable?

Knowledge check

Daily P&L of a strategy has first-order autocorrelation of +0.3. An i.i.d. bootstrap of the mean daily P&L will most likely:

Key takeaways

  • The bootstrap replaces FF by the empirical distribution: resample with replacement, recompute, and use the spread of the replicates. It works for any statistic you can compute.
  • Monte Carlo error falls with BB; the error from F^n≠F\hat F_n \ne F does not. Small samples give plug-in (divisor nn) answers that are too narrow.
  • It fails for extremes and non-smooth statistics, infinite-variance or very heavy-tailed data, and parameters on a boundary; mm-out-of-nn or parametric bootstraps help.
  • For dependent data use block, stationary or circular bootstraps with blocks longer than the correlation length; an i.i.d. bootstrap of autocorrelated P&L overstates significance.
  • Resample the independent unit and the whole pipeline.

Practice problems

Finished reading?

Answer the 3 knowledge checks to complete this lesson (0 done).