Bootstrap

Context: FIT2086_MOC · W10 · estimates a sampling distribution by resampling instead of deriving it · same family as Cross-Validation, different job · the -value counterpart ➔ Permutation Tests · bagging is the ancestor of Random Forest · relies on Monte Carlo averaging · Studio 10 R workflow ➔ Resampling Inference in R (boot, boot.ci, perm.log.reg) Parent Framework: Sampling Distribution of an Estimator

Quick Revision

  • 🎯 Objective: treat the sample as the population ➔ draw rows with replacement, times ➔ recompute each time ➔ the spread of gives bias, variance and percentile CIs with no distributional assumption.
  • 📦 Core Components: exact bootstrap ➔ all resamples, infeasible | bootstrap algorithm ➔ random resamples, often enough | bagging ➔ average models fitted to resamples.
  • ⚡ Key Constraint: resample with replacement, size , whole rows — without replacement every resample is a reshuffle of and never changes (zero spread); resampling columns separately destroys the pairing.

📝 How It Works

1. The Problem

  • Population–sample model ➔ population characterised by ; a finite sample of size gives ➔ how much would vary over new samples?
  • Classical route ➔ assume a population distribution, then derive the distribution of ➔ difficult or impossible, and only as good as the assumption. A sample mean needs weaker assumptions (CLT); a general statistic does not get that help.

2. The Exact Bootstrap

  • Idea (Efron, 1970s) ➔ the sample is an estimate of the population ➔ draw new samples from this surrogate population ➔ an empirical sampling distribution. Justified because sample probabilities are a consistent estimate of population probabilities as grows.
  • Enumerate ➔ all ordered samples of size with replacement, ➔ compute for each. The original plays the population value.
  • Bias ➔ .
  • Variance ➔ (divisor ).
  • Confidence interval ➔ percentiles of the .
  • Cost ➔ : at , at ⟹ infeasible almost immediately.

3. The Bootstrap Algorithm

  • For to () ➔ (1) draw a new sample of size with replacement from · (2) compute on it ➔ a resampling procedure.
  • Approximation ➔ approximate the exact bootstrap distribution; larger ⟹ closer; often works well.
  • Possible resamples of ➔ , , , — repeats allowed, some points absent.
  • Supervised data ➔ resample whole rows ( with its predictors): indices on the 9-row BP data ⟹ row appears three times, rows and not at all.

4. Bootstrapping Predictions and Errors

  • One model per resample ➔ fit BP on Age + Weight to each resample ⟹ , — a range of plausible models.
  • Prediction CI ➔ new individual (age , weight ): ➔ 95% CI [2.5th, 97.5th] percentiles of the predictions.
  • What it covers ➔ uncertainty in the predicted mean at ; an interval for one individual’s actual BP would also need the outcome noise.
  • Training MSE / AUC ➔ resample ➔ fit ➔ score on the same resample ➔ the bootstrap distribution quantifies the sampling variability of the in-sample score — but does not remove its optimistic bias (that is Cross-Validation’s job); Studio 10’s AUC case in §7.

5. Bagging

  • Bootstrap aggregation ➔ draw bootstrap samples ➔ fit a model to each ➔ predict new data by averaging the predictions (classification: majority vote).
  • When it helps ➔ low-bias / high-variance models — trees are the prime example ➔ averaging cancels their instability.
  • Lineage ➔ bagging inspired random forests, which add random feature selection at each split.

6. Strengths and Weaknesses

  • Strengths ➔ few distributional assumptions (standard bootstrap: observations independently sampled) · easy to code and apply · accuracy improves with .
  • Weaknesses ➔ slow when is slow to compute · poor accuracy at small · may need large for a smooth distribution · some problems need modifications first, e.g. the lasso.

7. Studio 10 — Interval Types and Hard Statistics

  • Three intervals for one mean ➔ interval (normal-theory) · basic bootstrap (bootstrap percentiles reflected about the observed statistic) · BCa (bias-corrected and accelerated: adjusts for bias and skewness in the bootstrap distribution) ➔ roughly symmetric data ⟹ all close. BSA (): · basic · BCa .
  • Any statistic, no formula ➔ median BSA vs mean ; bootstrap se vs ; basic CI vs ⟹ the median is the noisier estimator here — found by computation, no derivation (“computational power replaces mathematical cleverness”).
  • Spiky median distribution ➔ the median is the middle order statistic(s) — an observed value ( odd) or the average of two ( even) ⟹ many resamples share the same median ⟹ discrete spikes, tallest at the original median . Resistance in miniature: c(1,2,6,8,9), c(1,1,6,8,9), c(2,2,6,8,8) all have median .
  • Complex statistic ➔ AUC of a logistic regression refitted to each resampled Pima training set: BCa around a training AUC of ; the test AUC falls inside — yet every replicate is itself an in-sample AUC, so the interval inherits the optimism rather than correcting it.

🧮 Proof Blueprint

(Derivation not on the slides — it reproduces their and explains it.)

  • Theorem ➔ for the exact bootstrap gives and , .
  • Strategy ➔ one bootstrap draw picks each with probability ; the draws are iid; apply and of a mean.
  • Derivation Steps:
  • Q.E.D. ➔ the bootstrap standard error of a mean is — the plug-in version of ; for statistics with no such formula, the resampling loop does the same job numerically.

⚙️ Core Implementation

🔹 Bootstrapping a prediction (lecture code)

🔹 Bootstrapping any statistic + the exact check

⚖️ Core Decision Matrix

Resampling methodWhat is resampledDraw ruleEstimatesQuestion answered
Cross-Validationrows, split into disjoint foldspartition, no repeatsprediction error on future datahow well will it predict?
Bootstrapwhole rows with replacementsampling distribution of ➔ bias, se, CIhow variable is my estimate?
Permutation testtargets only, fixedshuffle, without replacementnull distribution of an association statistic ➔ -valueis there any association at all?

When It Flips: the question, not the data — uncertainty about ➔ bootstrap; evidence against "no association" ➔ permutation; future predictive error ➔ CV.

📊 Exam Execution Trace & Applied Exercises

Manual Execution Trace

Exact bootstrap of for , , :

  • Result ➔ mean of the 27 values ⟹ ; . Order matters: and are separate resamples.

Applied Exercise

Problem: , statistic . Exact bootstrap bias and variance.

Final Extracted Output: bias , Var — unlike the mean, the sample maximum is biased downward, and the bootstrap detects it without any distributional theory.

⚠️ Common Mistakes

  • 💡 CI for the mean read as an interval for an individual ➔ percentiles of bound the predicted mean at ; one person’s BP varies more.
  • 💡 Bootstrapping training MSE to “fix” optimism ➔ it quantifies the MSE’s variability only; the optimistic bias stays.
  • 💡 Trusting it at tiny ➔ the surrogate population is only as good as the sample; accuracy improves with , not with .

🧠 Active Recall