Skip to main content

Bootstrap in Regression

G6411 Recitation Notes

Author

Jesse Chieh Chen
cc5229@columbia.edu

Published

2026-11-30

This note implements the bootstrap methods for regression in R. For each method, we compare the bootstrap distribution computed from one sample with the actual sampling distribution, computed by Monte Carlo, and with the asymptotic normal approximation. This shows what each method gets right, what goes wrong when a method is misapplied, and, at the end, the asymptotic refinement of the percentile-\(t\) bootstrap.

library(tidyverse)

1 Setup

Consider \(Y_i=X_i^{\prime}\beta_0+u_i\) for \(i=1,...,n\), with OLS estimator \(\widehat\beta\), residuals \(\widehat u_i\), and heteroskedasticity-robust (or cluster-robust) standard errors \(s_j\). For \(H_0:\beta_j=\beta_{j,0}\), the \(t\)-statistic is \(T_n=(\widehat\beta_j-\beta_{j,0})/s_j\). Every bootstrap method below has the same three steps.

  1. Generate the bootstrap sample \(\{(Y_i^*,X_i^*)\}\) from data \(\{(Y_i,X_i)\}\).
  2. Re-estimate \(\widehat\beta^*\) and recompute the standard error \(s_j^*\) on the bootstrap sample, and form \[ T_n^*=\frac{\widehat\beta_j^*-\beta_j^\dagger}{s_j^*}, \] where \(\beta_j^\dagger\) is the true value of \(\beta_j\) in the bootstrap world. It could be \(\widehat\beta_j\) (unrestricted bootstrap) or \(\beta_{j,0}\) (restricted bootstrap).
  3. Repeat \(B\) times, and compute the bootstrap \(p\)-value \[ p^*=\frac1B\sum_{b=1}^B\mathbf{1}\left\{|T_n^{*(b)}|\ge|T_n|\right\}. \] Reject \(H_0\) at level \(\alpha\) if \(p^*\le\alpha\).

Note that the methods differ only in step 1. So in the code, each method is a function draw_*() that returns a function generating one bootstrap sample, and bootstrap() carries out steps 2 and 3.

First, OLS with cluster/heteroskedastic robust standard errors:

ols <- function(x, y, cluster = seq_along(y)) {
  xx_inv <- solve(crossprod(x))
  beta <- drop(xx_inv %*% crossprod(x, y))
  residuals <- drop(y - x %*% beta)
  scores <- rowsum(x * residuals, cluster)
  se2 <- xx_inv %*% crossprod(scores) %*% xx_inv
  list(
    beta = beta,
    se = sqrt(diag(se2)),
    residuals = residuals,
    fitted = y - residuals
  )
}
1
cluster identifies clusters; default is singleton clusters.
2
rowsum() adds up the scores within each cluster.
3
The typical sandwich formula for cluster/heteroskedastic robust standard errors.

Then the bootstrap loop and the \(p\)-value.

bootstrap <- function(draw, B, j, center) {
  bootstrap_indices <- seq_len(B)
  purrr::map(
    bootstrap_indices,
    function(b) {
      bootstrap_sample <- draw()
      fit <- ols(
        bootstrap_sample$x,
        bootstrap_sample$y,
        bootstrap_sample$cluster %||% seq_along(bootstrap_sample$y)
      )
      tibble::tibble(
        estimate = fit$beta[j],
        t = (fit$beta[j] - center) / fit$se[j]
      )
    }
  ) |>
    purrr::list_rbind()
}

boot_pvalue <- function(t_star, t_obs) {
  mean(abs(t_star) >= abs(t_obs))
}
1
Step 1: draw() returns one bootstrap sample list(x, y), or list(x, y, cluster) with clustered data.
2
Step 2: re-estimate and recompute the standard error on the bootstrap sample. %||% uses singleton clusters when draw() returns no cluster.
3
The bootstrap t-statistic, centered at center, the true value of the coefficient in the bootstrap world.
4
t_star is a vector of bootstrap t-statistics, and t_obs is the observed t-statistic.

Each figure below compares three things:

  1. Sampling distribution (gray histogram, from Monte Carlo),
  2. Bootstrap distributions from one sample (red lines),
  3. Asymptotic normal approximation (blue dashed lines).
Plotting function
normal_curve <- function(x, sd) {
  grid <- seq(min(x), max(x), length.out = 401)
  tibble::tibble(value = grid, density = dnorm(grid, sd = sd))
}

plot_against_truth <- function(truth, boot, xlab, binwidth, asymptotic_sd) {
  ggplot2::ggplot() +
    ggplot2::geom_histogram(
      data = tibble::tibble(value = truth),
      ggplot2::aes(x = value, y = ggplot2::after_stat(density)),
      binwidth = binwidth,
      fill = "gray85",
      colour = "gray60",
      linewidth = 0.2
    ) +
    ggplot2::geom_line(
      data = normal_curve(c(truth, boot$value), asymptotic_sd),
      ggplot2::aes(x = value, y = density),
      colour = "blue",
      linetype = "dashed"
    ) +
    ggplot2::geom_density(
      data = boot,
      ggplot2::aes(x = value),
      colour = "red",
      linewidth = 0.8
    ) +
    ggplot2::facet_wrap(~method, nrow = 1) +
    ggplot2::labs(x = xlab, y = "Density")
}

2 Cross-Sectional Regression

In this section, the data are generated by \[ Y_i=\beta_1X_i+|X_i|e_i, \qquad X_i,e_i\overset{\text{iid}}{\sim}\mathcal{N}(0,1), \tag{1}\] with \(\beta_1=0\), and we regress \(Y_i\) on \((1,X_i)\). The error \(u_i=|X_i|e_i\) is heteroskedastic with \(\operatorname{Var}(u_i\,|\,X_i)=X_i^2\).

simulate_heteroskedastic <- function(n, beta1 = 0) {
  x <- rnorm(n)
  list(
    x = cbind(1, x),
    y = beta1 * x + abs(x) * rnorm(n)
  )
}

2.1 Three Bootstrap Methods

NoteDefinition: Pairs Bootstrap

Draw the rows \((Y_i^*,X_i^*)\) with replacement from \(\{(Y_i,X_i)\}_{i=1}^n\).

draw_pairs <- function(x, y, cluster = seq_along(y)) {
  rows <- split(seq_along(y), cluster)
  function() {
    picked <- rows[sample(length(rows), replace = TRUE)]
    picked_indices <- unlist(picked)
    cluster <- rep(seq_along(picked), lengths(picked))
    list(
      x = x[picked_indices, , drop = FALSE],
      y = y[picked_indices],
      cluster = cluster
    )
  }
}
1
The rows of each cluster; with singleton clusters, each row on its own. The same function is the cluster pairs bootstrap of Section 4.
2
A cluster drawn twice counts as two distinct clusters.
NoteDefinition: Residual Bootstrap

Draw \(u_1^*,...,u_n^*\) with replacement from the centered residuals \(\widehat u_i-\overline{\widehat u}\), and set \(Y_i^*=X_i^{\prime}\widehat\beta+u_i^*\), holding \(X_i\) fixed.

draw_residual <- function(x, y, fit = ols(x, y)) {
  u <- fit$residuals - mean(fit$residuals)
  function() {
    u_star <- sample(u, replace = TRUE)
    list(
      x = x,
      y = fit$fitted + u_star
    )
  }
}
1
Centering gives the bootstrap errors mean zero; with an intercept, the residuals already average to zero.
2
Each bootstrap error is drawn from all residuals, regardless of its row of x: the bootstrap world is homoskedastic. The draw happens inside the returned function(), so every replication gets fresh residuals.
NoteDefinition: Wild Bootstrap

Set \(Y_i^*=X_i^{\prime}\widehat\beta+\widehat u_i\xi_i\), holding \(X_i\) fixed, where \(\xi_i\) are iid and independent of the data, with \(\mathbb{E}\xi_i=0\) and \(\mathbb{E}\xi_i^2=1\).

draw_wild <- function(
  x,
  y,
  cluster = seq_along(y),
  fit = ols(x, y),
  weights = rademacher
) {
  cluster_index <- match(cluster, unique(cluster))
  function() {
    xi <- weights(max(cluster_index))
    list(
      x = x,
      y = fit$fitted + fit$residuals * xi[cluster_index],
      cluster = cluster
    )
  }
}

rademacher <- function(G) {
  sample(c(-1, 1), G, replace = TRUE)
}

mammen <- function(G) {
  a <- (sqrt(5) - 1) / 2
  sample(c(-a, a + 1), G, replace = TRUE, prob = c(a + 1, a) / sqrt(5))
}
1
Cluster index (1, …, G) of each observation.
2
Each residual stays with its own observation and is only multiplied by a weight, so every bootstrap error keeps its own variance: the bootstrap world keeps the heteroskedasticity. All observations of a cluster share one weight (Section 4). Passing a restricted fit imposes the null (Section 3).
3
Rademacher weights: -1 or 1 with probability 1/2 each.
4
Mammen’s weights also have third moment 1, which matters for Section 7.

2.2 Simulation

Now let’s look at how the three bootstrap methods perform in Equation 1 with \(n=100\).

set.seed(2026)
n <- 100
B <- 9999

truth <- 1:20000 |>
  purrr::map_dbl(
    function(r) {
      sample <- simulate_heteroskedastic(n)
      ols(sample$x, sample$y)$beta[2]
    }
  )

sample <- simulate_heteroskedastic(n)

fit <- ols(sample$x, sample$y)

boot_pairs <- draw_pairs(sample$x, sample$y) |>
  bootstrap(B, j = 2, center = fit$beta[2])
boot_residual <- draw_residual(sample$x, sample$y) |>
  bootstrap(B, j = 2, center = fit$beta[2])
boot_wild <- draw_wild(sample$x, sample$y) |>
  bootstrap(B, j = 2, center = fit$beta[2])

boot <- dplyr::bind_rows(
  "Pairs" = boot_pairs,
  "Residual" = boot_residual,
  "Wild" = boot_wild,
  .id = "method"
) |>
  dplyr::mutate(
    method = forcats::fct_inorder(method),
    value = estimate - fit$beta[2]
  )

sds <- boot |>
  dplyr::summarise(sd = sd(value), .by = method) |>
  tibble::deframe()
1
The sampling distribution of the slope’s estimation error, from 20000 Monte Carlo samples.
2
One sample, from which all three bootstraps are computed.
3
Stack the three sets of bootstrap draws, with a method column naming the bootstrap.
4
value is the bootstrap estimation error, the bootstrap estimate minus the original estimate.

To visualize the results, we plot the sampling distribution, the bootstrap distributions, and the asymptotic normal approximation.

plot_against_truth(
  truth,
  boot,
  "Estimation error",
  binwidth = 0.02,
  asymptotic_sd = sqrt(3 / n)
)
1
The asymptotic variance of the scaled slope estimate is 3, derived below.
Figure 1: Equation 1 with \(n=100\): sampling distribution of \(\widehat\beta_1-\beta_1\) (histogram), bootstrap distributions of \(\widehat\beta_1^*-\widehat\beta_1\) (red, \(B=9{,}999\)), and the asymptotic \(\mathcal{N}(0,3/n)\) (blue dashed).

The asymptotic variance of \(\sqrt n(\widehat\beta_1-\beta_1)\) is \(\mathbb{E}(X_i^2u_i^2)/(\mathbb{E}X_i^2)^2=\mathbb{E}X_i^4=3\). In Figure 1, the pairs and wild bootstrap distributions match the sampling distribution, with standard deviations 0.163 and 0.165 against the true 0.172.

WarningMisapplied: Residual Bootstrap under Heteroskedasticity

The residual bootstrap draws \(u_i^*\) independently of \(X_i\), so its bootstrap world is homoskedastic, and its standard deviation is only 0.098. It estimates the homoskedastic asymptotic variance \(\mathbb{E}u_i^2/\mathbb{E}X_i^2=1\) instead of \(3\), and indeed 0.172\(/\sqrt3\approx\) 0.099. The large errors occur at large \(|X_i|\), which are the observations that determine the slope.

3 Imposing the Null

Partition \(X_i=(X_{1i},X_{2i}^{\prime})^{\prime}\) and consider \(H_0:\beta_1=\beta_{1,0}\). Regress \(Y_i-X_{1i}\beta_{1,0}\) on \(X_{2i}\) to obtain the restricted estimate \(\widetilde\beta_2\) and residuals \(\widetilde u_i\).

NoteDefinition: Restricted Wild Bootstrap

Generate \(Y_i^*=X_{1i}\beta_{1,0}+X_{2i}^{\prime}\widetilde\beta_2+\widetilde u_i\xi_i\), estimate the unrestricted regression of \(Y_i^*\) on \(X_i\), and form \[ T_n^*=\frac{\widehat\beta_1^*-\beta_{1,0}}{s_1^*}. \]

The null is imposed when generating the bootstrap data, not when estimating the bootstrap regression. In code, a restricted fit replaces the unrestricted one in draw_wild():

ols_restricted <- function(x, y, j, b0) {
  offset <- x[, j] * b0
  fit <- ols(x[, -j, drop = FALSE], y - offset)
  list(fitted = fit$fitted + offset, residuals = fit$residuals)
}
1
The part of the fitted values fixed by the null: column j of x times b0.
2
The restricted fitted values and residuals, in the form draw_wild() expects.

To see the role of centering, we test the false \(H_0:\beta_1=0\) in one sample from Equation 1 with \(\beta_1=0.5\), with three versions of the wild bootstrap:

set.seed(2026)
sample <- simulate_heteroskedastic(n, beta1 = 0.5)
fit <- ols(sample$x, sample$y)
t_obs <- unname(fit$beta[2] / fit$se[2])
fit_null <- ols_restricted(sample$x, sample$y, j = 2, b0 = 0)

tests <- list(
  "Unrestricted, centered at estimate" = bootstrap(
    draw_wild(sample$x, sample$y),
    B,
    j = 2,
    center = fit$beta[2]
  ),
  "Restricted, centered at null" = bootstrap(
    draw_wild(sample$x, sample$y, fit = fit_null),
    B,
    j = 2,
    center = 0
  ),
  "Restricted, centered at estimate" = bootstrap(
    draw_wild(sample$x, sample$y, fit = fit_null),
    B,
    j = 2,
    center = fit$beta[2]
  )
)

pvalues <- tests |>
  purrr::map_dbl(
    function(draws) boot_pvalue(draws$t, t_obs)
  )

truth <- purrr::map_dbl(1:20000, function(r) {
  sample <- simulate_heteroskedastic(n, beta1 = 0.5)
  fit <- ols(sample$x, sample$y)
  (fit$beta[2] - 0.5) / fit$se[2]
})
1
Correct: in the unrestricted bootstrap world, the true slope is the estimate.
2
Correct: in the restricted bootstrap world, the true slope is the null value 0.
3
Wrong: data generated under the null, but centered at the estimate.
4
The sampling distribution of the t-statistic centered at the true slope 0.5, from 20000 Monte Carlo samples. This is what a correctly centered bootstrap t-statistic approximates.
Plotting code
boot <- dplyr::bind_rows(tests, .id = "method") |>
  dplyr::mutate(
    method = forcats::fct_inorder(sprintf(
      "%s\np = %.3f",
      method,
      pvalues[method]
    )),
    value = t
  )

plot_against_truth(
  truth,
  boot,
  expression(T[n] ~ "and" ~ T[n]^"*"),
  binwidth = 0.2,
  asymptotic_sd = 1
) +
  ggplot2::geom_vline(xintercept = c(-1, 1) * t_obs, linetype = "dotted")
Figure 2: Testing \(H_0:\beta_1=0\) in one sample from Equation 1 with \(\beta_1=0.5\): sampling distribution of \((\widehat\beta_1-\beta_1)/s_1\) (histogram, 20,000 Monte Carlo samples), wild bootstrap distributions of \(T_n^*\) (red, \(B=9{,}999\)), \(\mathcal{N}(0,1)\) (blue dashed), and \(\pm T_n\) (dotted).

Here \(T_n=\) 2.922. In Figure 2, the unrestricted and restricted bootstraps, correctly centered, give \(p^*=\) 0.012 and \(p^*=\) 0.010.

WarningMisapplied: Centering at the Wrong Value

The third panel generates data under \(H_0\) but centers at \(\widehat\beta_1\). Since \(\widehat\beta_1^*\approx\beta_{1,0}\) in this bootstrap world, \(T_n^*\approx(\beta_{1,0}-\widehat\beta_1)/s_1^*\) is centered near \(-T_n\) instead of zero, so \(|T_n^*|\) is typically as large as \(|T_n|\), and \(p^*=\) 0.437. The more false \(H_0\) is, the further \(T_n^*\) shifts, so this test has essentially no power. The rule: center \(T_n^*\) at the true value of \(\beta_1\) in the bootstrap world.

4 Clustered Data

Suppose there are \(G\) independent clusters with dependence within each cluster. The cluster versions of the pairs and wild bootstrap treat the cluster as the unit of resampling.

NoteDefinition: Cluster Pairs and Wild Cluster Bootstrap

The cluster pairs bootstrap draws \(G\) clusters with replacement and keeps all observations of each drawn cluster. The wild cluster bootstrap sets \(Y_i^*=X_i^{\prime}\widehat\beta+\widehat u_i\xi_g\) for \(i\) in cluster \(g\), with one multiplier \(\xi_g\) per cluster, so that \(\mathbb{E}^*(u_i^*u_k^*)=\widehat u_i\widehat u_k\) within a cluster and zero across clusters.

Both are draw_pairs() and draw_wild() with the cluster identifiers passed as cluster. We generate \(G\) clusters of \(m=10\) observations by \[ Y_{gi}=\beta_1X_{gi}+u_{gi}, \qquad X_{gi}=a_g+e_{gi}, \qquad u_{gi}=b_g+\varepsilon_{gi}, \tag{2}\] with \(a_g,b_g,e_{gi},\varepsilon_{gi}\overset{\text{iid}}{\sim}\mathcal{N}(0,1)\) and \(\beta_1=0\), so both \(X_{gi}\) and \(u_{gi}\) have within-cluster correlation \(1/2\).

simulate_clustered <- function(G, m = 10, beta1 = 0) {
  g <- rep(seq_len(G), each = m)
  x <- rnorm(G)[g] + rnorm(G * m)
  u <- rnorm(G)[g] + rnorm(G * m)
  list(x = cbind(1, x), y = beta1 * x + u, cluster = g)
}
1
rnorm(G)[g] gives all observations of a cluster the same cluster component.
set.seed(2026)
G <- 20
m <- 10

truth <- purrr::map_dbl(1:20000, function(r) {
  sample <- simulate_clustered(G)
  ols(sample$x, sample$y)$beta[2]
})

sample <- simulate_clustered(G)
fit <- ols(sample$x, sample$y, sample$cluster)
boot_cluster_pairs <- bootstrap(
  draw_pairs(sample$x, sample$y, sample$cluster),
  B,
  j = 2,
  center = fit$beta[2]
)
boot_wild_cluster <- bootstrap(
  draw_wild(sample$x, sample$y, sample$cluster),
  B,
  j = 2,
  center = fit$beta[2]
)
boot_wild_ignoring <- bootstrap(
  draw_wild(sample$x, sample$y),
  B,
  j = 2,
  center = fit$beta[2]
)

boot <- dplyr::bind_rows(
  "Cluster pairs" = boot_cluster_pairs,
  "Wild cluster" = boot_wild_cluster,
  "Wild, ignoring clusters" = boot_wild_ignoring,
  .id = "method"
) |>
  dplyr::mutate(
    method = forcats::fct_inorder(method),
    value = estimate - fit$beta[2]
  )

sds <- boot |>
  dplyr::summarise(sd = sd(value), .by = method) |>
  tibble::deframe()
1
Wrong: one multiplier per observation.
asymptotic_sd <- sqrt((4 * m + m * (m - 1)) / (G * (2 * m)^2))
plot_against_truth(
  truth,
  boot,
  "Estimation error",
  binwidth = 0.02,
  asymptotic_sd = asymptotic_sd
)
1
The asymptotic standard deviation of the slope, derived below.
Figure 3: Equation 2 with \(G=20\) clusters of size \(10\): sampling distribution of \(\widehat\beta_1-\beta_1\) (histogram), bootstrap distributions of \(\widehat\beta_1^*-\widehat\beta_1\) (red, \(B=9{,}999\)), and the asymptotic normal approximation (blue dashed).

The asymptotic variance of \(\widehat\beta_1\) is \(\operatorname{Var}\bigl(\sum_iX_{gi}u_{gi}\bigr)/\bigl(G(\mathbb{E}\sum_iX_{gi}^2)^2\bigr)\), with \(\operatorname{Var}\bigl(\sum_iX_{gi}u_{gi}\bigr)=m\cdot2\cdot2+m(m-1)\) and \(\mathbb{E}\sum_iX_{gi}^2=2m\). In Figure 3, the cluster pairs and wild cluster bootstraps have standard deviations 0.133 and 0.132 against the true 0.128.

WarningMisapplied: Ignoring the Clusters

The wild bootstrap with one multiplier per observation makes \(u_i^*\) independent within clusters, so it misses the within-cluster correlation of the scores and has standard deviation 0.079. The variance ratio is roughly \(1+(m-1)\rho_X\rho_u=1+9\cdot\frac12\cdot\frac12=3.25\), and 0.128\(/\sqrt{3.25}\approx\) 0.071.

5 Size in Small Samples

How accurate are these tests under a true null? Table 1 reports the rejection rates of \(5\%\) tests of \(H_0:\beta_1=0\), in Equation 1 and in the clustered design of Section 4, where pairs and wild resample whole clusters. The simulation applies the bootstraps above to 2,000 Monte Carlo samples per design; its code is omitted here.

Table 1: Rejection rates of 5% tests of the true \(H_0:\beta_1=0\) (2,000 Monte Carlo samples, \(B=399\)). Normal: \(|T_n|>1.96\).
Heteroskedastic, \(n=20\) Heteroskedastic, \(n=40\) Clustered, \(G=10\) Clustered, \(G=20\)
Normal 0.158 0.108 0.150 0.112
Pairs 0.050 0.048 0.046 0.056
Wild 0.072 0.056 0.071 0.065
Wild, restricted 0.050 0.044 0.050 0.050

With 2,000 samples, the Monte Carlo standard error is about \(0.005\).1

  1. The normal approximation over-rejects badly, e.g., 0.158 with \(n=20\) and 0.150 with \(G=10\), since robust standard errors are biased downward in small samples.
  2. The unrestricted wild bootstrap helps but still over-rejects, while the restricted wild bootstrap is close to \(0.05\) in every design.

6 Time Series Regression

Consider the AR(1) model \(Y_t=c+\phi Y_{t-1}+u_t\) for \(t=2,...,T\), a regression of \(Y_t\) on \(X_t=(1,Y_{t-1})^{\prime}\).

NoteDefinition: Pairs and Residual Bootstrap for AR(1)

The pairs bootstrap draws the rows \((Y_t,X_t)\) with replacement, as in the cross-section. The residual bootstrap draws \(u_t^*\) with replacement from the centered residuals and generates a new series recursively from the observed \(Y_1\): \[ Y_1^*=Y_1, \qquad Y_t^*=\widehat c+\widehat\phi Y_{t-1}^*+u_t^*, \quad t=2,...,T. \]

draw_ar_residual <- function(y) {
  x <- cbind(1, head(y, -1))
  fit <- ols(x, y[-1])
  u <- fit$residuals - mean(fit$residuals)
  function() {
    shocks <- fit$beta[1] + sample(u, replace = TRUE)
    y_star <- stats::filter(shocks, fit$beta[2], "recursive", init = y[1])
    y_star <- c(y[1], y_star)
    list(x = cbind(1, head(y_star, -1)), y = y_star[-1])
  }
}
1
The fitted intercept plus a resampled residual, for periods 2 to T.
2
Run the AR(1) recursion with the fitted coefficient, starting from the observed first value y[1].
3
Rebuild the regression of the new series on a constant and its first lag.

The resampled rows of the pairs bootstrap are not a time series, but the pairs bootstrap is still first-order valid if \(X_tu_t\) is a martingale difference sequence, since then the asymptotic variance of \(\widehat\beta\) involves only \(\mathbb{E}(X_tX_t^{\prime}u_t^2)\). The residual bootstrap requires iid innovations, and generally fails under conditional heteroskedasticity.

set.seed(2026)
n <- 200
phi <- 0.9

ar_fit <- function(y) ols(cbind(1, head(y, -1)), y[-1])
simulate_ar1 <- function(n, phi) as.numeric(arima.sim(list(ar = phi), n))

truth <- purrr::map_dbl(
  1:20000,
  function(r) ar_fit(simulate_ar1(n, phi))$beta[2] - phi
)

set.seed(31)
y <- simulate_ar1(n, phi)
fit <- ar_fit(y)
boot_pairs <- bootstrap(
  draw_pairs(cbind(1, head(y, -1)), y[-1]),
  B,
  j = 2,
  center = fit$beta[2]
)
boot_residual <- bootstrap(draw_ar_residual(y), B, j = 2, center = fit$beta[2])

boot <- dplyr::bind_rows(
  "Pairs" = boot_pairs,
  "Residual" = boot_residual,
  .id = "method"
) |>
  dplyr::mutate(
    method = forcats::fct_inorder(method),
    value = estimate - fit$beta[2]
  )
means <- boot |>
  dplyr::summarise(mean = mean(value), .by = method) |>
  tibble::deframe()
1
A typical sample: its estimate of phi is near the median of the sampling distribution above.
plot_against_truth(
  truth,
  boot,
  "Estimation error",
  binwidth = 0.005,
  asymptotic_sd = sqrt((1 - phi^2) / (n - 1))
)
1
The asymptotic standard deviation of the AR coefficient, with n - 1 observations in the regression.
Figure 4: AR(1) with \(c=0\), \(\phi=0.9\), \(\mathcal{N}(0,1)\) innovations, and \(T=200\): sampling distribution of \(\widehat\phi-\phi\) (histogram), bootstrap distributions of \(\widehat\phi^*-\widehat\phi\) (red, \(B=9{,}999\)), and the asymptotic \(\mathcal{N}(0,(1-\phi^2)/(T-1))\) (blue dashed).

Three things stand out in Figure 4.

  1. Although we have the asymptotic result \(\sqrt T(\widehat\phi-\phi)\leadsto\mathcal{N}(0,1-\phi^2)\), we can clearly see that in finite samples, there is both a bias and a skew in the sampling distribution, neither of which is captured by the asymptotic normal approximation. The mean of \(\widehat\phi-\phi\) is -0.019. The bias arises because \(u_t\) enters every later regressor \(Y_t,Y_{t+1},...\): the regressor \(Y_{t-1}\) is only predetermined, not strictly exogenous.
  2. The residual bootstrap generates entire new series from the fitted AR(1). In its bootstrap world, \(u_t^*\) enters \(Y_t^*,Y_{t+1}^*,...\) exactly as \(u_t\) enters \(Y_t,Y_{t+1},...\) in the real world, so OLS on the bootstrap series has the same bias, evaluated at \(\widehat\phi\) instead of \(\phi\): the mean of \(\widehat\phi^*-\widehat\phi\) is -0.020, against the true -0.019, and its distribution has the same left skew.
  3. The pairs bootstrap draws the rows \((Y_t,Y_{t-1})\) independently, so its bootstrap sample is not a time series: the error of one row has nothing to do with the regressors of the other rows. This removes the source of the bias, and \(\widehat\phi^*-\widehat\phi\) is centered at zero (mean 0.000), much like the asymptotic approximation.

7 Asymptotic Refinement

To see the refinement, regress \(Y_i\) on a constant only, \[ Y_i=\beta+u_i, \qquad u_i=e_i-1, \qquad e_i\overset{\text{iid}}{\sim}\text{Exp}(1), \tag{3}\] so \(\widehat\beta=\overline Y_n\) and \(T_n=(\overline Y_n-\beta)/s\) with \(s=\widehat\sigma_n/\sqrt n\). The errors are strongly skewed, with \(\mathbb{E}u_i^3=2\).

Under regularity conditions, \[ P(T_n\le t)=\Phi(t)+n^{-1/2}q(t)\varphi(t)+O(n^{-1}), \] where \(\Phi\) and \(\varphi\) are the standard normal CDF and density, and \(q\) is an even polynomial whose coefficients depend on the skewness of \(u_i\). The normal approximation drops the second term, so its error is \(O(n^{-1/2})\). The bootstrap \(T_n^*\) has the same expansion with \(q\) evaluated at the bootstrap world, so its error is \(O_p(n^{-1})\) if the bootstrap world reproduces the skewness of \(u_i\).

  1. The pairs bootstrap draws from the empirical distribution, whose skewness estimates that of \(u_i\).
  2. With Rademacher weights, \(u_i^*=\widehat u_i\xi_i\) is symmetric, so \(\mathbb{E}^*u_i^{*3}=0\) and \(T_n^*\) is symmetric.
  3. Mammen’s weights satisfy \(\mathbb{E}\xi_i^3=1\), so \(\mathbb{E}^*u_i^{*3}=\widehat u_i^3\).
  4. Without studentization, the distribution of \(\widehat\beta^*-\widehat\beta\) depends on \(\widehat\sigma_n\), which estimates \(\sigma\) with error \(O_p(n^{-1/2})\).

So the pairs percentile-\(t\) and the Mammen wild percentile-\(t\) should have one-sided errors \(O(n^{-1})\), and the other two \(O(n^{-1/2})\).

set.seed(2026)
n <- 20
x <- matrix(1, n)

truth <- purrr::map_dbl(1:1e5, function(r) {
  fit <- ols(x, rexp(n) - 1)
  fit$beta / fit$se
})

set.seed(55)
y <- rexp(n) - 1
fit <- ols(x, y)
boot_pairs <- bootstrap(draw_pairs(x, y), B, j = 1, center = fit$beta)
boot_rademacher <- bootstrap(draw_wild(x, y), B, j = 1, center = fit$beta)
boot_mammen <- bootstrap(
  draw_wild(x, y, weights = mammen),
  B,
  j = 1,
  center = fit$beta
)

boot <- dplyr::bind_rows(
  "Pairs" = boot_pairs,
  "Wild, Rademacher" = boot_rademacher,
  "Wild, Mammen" = boot_mammen,
  .id = "method"
) |>
  dplyr::mutate(method = forcats::fct_inorder(method), value = t)
1
Here we keep the bootstrap t-statistics, not the estimates.
2
A typical sample: its skewness is near the median for samples of this size.
plot_against_truth(
  truth,
  boot,
  expression(T[n] ~ "and" ~ T[n]^"*"),
  binwidth = 0.1,
  asymptotic_sd = 1
) +
  ggplot2::coord_cartesian(xlim = c(-6, 4))
Figure 5: Equation 3 with \(n=20\): sampling distribution of \(T_n\) (histogram, 100,000 Monte Carlo samples), bootstrap distributions of \(T_n^*\) (red, \(B=9{,}999\)), and \(\mathcal{N}(0,1)\) (blue dashed).

In Figure 5, \(T_n\) is skewed to the left: with right-skewed errors, a large \(\overline Y_n\) tends to come with a large \(\widehat\sigma_n\), so large positive deviations are shrunk while large negative ones are not. The pairs \(T_n^*\) reproduces the long left tail, the Mammen \(T_n^*\) partly reproduces it, and the Rademacher \(T_n^*\) is symmetric, so it cannot capture the skewness.

To see the rates, we compute rejection rates of \(5\%\) tests of the true \(H_0\) for \(n\) from 10 to 160. This takes 50,000 Monte Carlo samples with \(B=999\) for each \(n\), so the simulation vectorizes the bootstraps above for speed; its code is omitted here.

Figure 6: Equation 3: absolute error of the rejection rate of \(5\%\) tests of the true \(H_0\) against \(n\), on log scales (50,000 Monte Carlo samples, \(B=999\)). One-sided tests reject for small \(T_n\). Dashed lines have slopes \(-1/2\) and \(-1\); the dotted line is the Monte Carlo standard error.

Figure 6 confirms the predicted rates.

  1. One-sided: the errors of the normal approximation, the non-studentized pairs bootstrap, and the Rademacher wild bootstrap are parallel to \(n^{-1/2}\); the normal test rejects 12.2% at \(n=20\) and 7.3% at \(n=160\). The pairs percentile-\(t\) and Mammen wild bootstraps fall at least as fast as \(n^{-1}\) until they approach the Monte Carlo noise level at \(n=160\); the pairs percentile-\(t\) test rejects 6.6% at \(n=20\) and 5.3% at \(n=160\).
  2. Two-sided (symmetric): since \(q\) and \(\varphi\) are both even, the \(n^{-1/2}\) terms of the two tails cancel, \[ \begin{aligned} P(|T_n|\le t) &=P(T_n\le t)-P(T_n<-t)\\ &=\Phi(t)-\Phi(-t)+n^{-1/2}\bigl[q(t)\varphi(t)-q(-t)\varphi(-t)\bigr]+O(n^{-1})\\ &=2\Phi(t)-1+O(n^{-1}). \end{aligned} \] So even the normal approximation has error \(O(n^{-1})\), and all methods improve faster than in the one-sided case. The symmetric percentile-\(t\) test is still the most accurate at every \(n\).

In practice, Rademacher weights are the usual default for two-sided tests, but for one-sided tests or intervals with skewed errors, the pairs or Mammen wild percentile-\(t\) is preferable.

Footnotes

  1. Each rejection rate in Table 1 is itself an estimate: the fraction of the \(R=2{,}000\) simulated samples in which the test rejects. If the test’s true rejection probability is \(p\), this fraction has standard error \(\sqrt{p(1-p)/R}\), which is \(\sqrt{0.05\cdot0.95/2000}\approx0.005\) for a correctly sized test with \(p=0.05\). So rates within about \(0.01\) of \(0.05\) are consistent with correct size, and larger deviations reflect the test, not simulation noise.↩︎