Statistics · Resampling

BOOTSTRAP

Estimate sampling uncertainty by repeatedly resampling observed cases or fitted regression residuals. Returns bias, bootstrap standard errors, confidence intervals, and inspectable empirical distributions.

Series Regression Deterministic by default D3 result Extractable

Syntax

Regression residual bootstrap

BOOTSTRAP(regression, replications)
BOOTSTRAP(regression, replications, seed)

Series case bootstrap

BOOTSTRAP(series, replications)
BOOTSTRAP(series, replications, seed)
The optional seed makes a run explicitly reproducible. Without it, RainbowStats derives a stable seed from the source data and requested replication count.

Regression mode

Uses a fixed-design residual bootstrap. The original explanatory variables remain unchanged while model errors are resampled.

  1. Fit the supplied regression and collect fitted values and residuals.
  2. Center the residuals so their empirical mean is zero.
  3. Sample centered residuals with replacement.
  4. Construct a new response and recompute every OLS coefficient.
  5. Repeat B times and summarize each coefficient distribution.
y*i = ŷi + e*i    and    β̂* = (X′X)−1X′y*

This estimates coefficient uncertainty under the fitted model while preserving the observed design matrix X.

Series mode

Uses the ordinary nonparametric case bootstrap for the sample mean.

  1. Remove non-finite observations from the input series.
  2. Draw n observations with replacement from the observed values.
  3. Compute the mean of the resampled observations.
  4. Repeat B times to form the empirical mean distribution.
  5. Report bias, standard error, and confidence intervals.
x*1, …, x*n ∼ F̂n    and    θ̂* = mean(x*)

Use regression mode when the statistic of interest is a fitted model coefficient rather than the level of a single series.

Parameters

ParameterTypeRequiredDescription
source Series or Regression Yes A data series for a mean bootstrap, or a fitted OLS regression for a residual bootstrap.
replications Number Yes Number of bootstrap samples, rounded to an integer. Must be from 100 through 50,000.
seed Number No Random seed for exact replay. Numeric values are rounded to the nearest integer.

Example: bootstrap a regression

In the two-series regression form, the first series is the response and the second series is the explanatory variable.

# U-6 rate regressed on the unemployment rate
R=REGRESSION(U6RATE,UNRATE)
SLIDESHOW(BOOTSTRAP(R,500))

The result contains a summary table followed by a histogram for each bootstrapped regression coefficient.

Example: bootstrap a mean

# Empirical uncertainty of a series mean
SLIDESHOW(BOOTSTRAP(UNRATE,2000,42))

This resamples the observed values of UNRATE and reports uncertainty for its sample mean.

Reported statistics

StatisticMeaning
EstimateStatistic or coefficient from the original sample.
Bootstrap meanMean of the B bootstrap estimates.
BiasBootstrap mean minus the original estimate.
Bootstrap SESample standard deviation of bootstrap estimates.
Percentile CI2.5th and 97.5th percentiles of the empirical distribution.
Basic CIPivotal interval reflected around the original estimate.

Extractable results

Use EXTRACT to retrieve a panel, vector, matrix, or distribution.

summary slideshow draws estimate bootstrap_mean bias standard_error percentile_lower_ci percentile_upper_ci lower_ci upper_ci distribution beta0 … betaN
# Examples
SE=EXTRACT(B,standard_error)
SLOPE_DRAWS=EXTRACT(B,beta1)
ALL_DRAWS=EXTRACT(B,draws)

distribution is available directly when the result has one statistic. For regressions, use beta0 through betaN, or the normalized coefficient column name.

Interpretation and scope

A narrow bootstrap distribution indicates a stable estimate under resampling; a wide distribution indicates greater sampling uncertainty. Bias near zero means the center of the bootstrap distribution is close to the original estimate.

Important distinction: residual-based regression search evaluates or selects candidate models using their residual behavior. BOOTSTRAP does something different: it actually resamples residuals to approximate the sampling distribution of fitted coefficients.

Fixed-design residual resampling assumes the fitted regression is an appropriate data-generating approximation and that its errors are exchangeable. For strong heteroskedasticity, autocorrelation, or clustered observations, use a bootstrap designed for that structure.