๐Ÿงฎ Brain Teaser

The Variance of Bagging

Let f^1,f^2,โ€ฆ,f^B\hat{f}_1, \hat{f}_2, \ldots, \hat{f}_B be BB identically distributed predictors, each with variance ฯƒ2\sigma^2. Suppose any two distinct predictors have correlation ฯโˆˆ[0,1]\rho \in [0,1].

The bagged predictor is the simple average: f^bag=1Bโˆ‘b=1Bf^b.\hat{f}_{\text{bag}} = \frac{1}{B} \sum_{b=1}^B \hat{f}_b.

(a) Compute Var(f^bag)\mathrm{Var}(\hat{f}_{\text{bag}}) as a function of BB, ฯƒ2\sigma^2, and ฯ\rho.

(b) What happens as Bโ†’โˆžB \to \infty? What does this tell you about when bagging helps and when it doesn't?

(c) Now suppose you use a biased base learner: each f^b\hat{f}_b has bias ฮฒ\beta (i.e., E[f^b]=fโˆ—+ฮฒE[\hat{f}_b] = f^* + \beta where fโˆ—f^* is the true function). Does averaging over BB bootstrapped copies reduce bias? What is the fundamental limitation of bagging?

baggingbias-variancebootstrapcorrelationensemble methods

Answer: The Variance of Bagging

Key Idea / Intuition

Averaging BB copies of a random variable reduces variance โ€” but only the independent part of the variance vanishes. The correlated part is irreducible no matter how many copies you average. This is the core tension in bagging: bootstrap samples from the same training set are highly correlated, so the variance reduction hits a floor. Meanwhile, averaging never touches bias at all.


Formal Proof / Solution

Part (a): Variance of the Bagged Predictor

We expand directly:

Var(f^bag)=Varโ€‰โฃ(1Bโˆ‘b=1Bf^b)=1B2Varโ€‰โฃ(โˆ‘b=1Bf^b).\mathrm{Var}(\hat{f}_{\text{bag}}) = \mathrm{Var}\!\left(\frac{1}{B}\sum_{b=1}^B \hat{f}_b\right) = \frac{1}{B^2} \mathrm{Var}\!\left(\sum_{b=1}^B \hat{f}_b\right).

Expanding the variance of the sum:

Varโ€‰โฃ(โˆ‘b=1Bf^b)=โˆ‘b=1BVar(f^b)+โˆ‘bโ‰ bโ€ฒCov(f^b,f^bโ€ฒ).\mathrm{Var}\!\left(\sum_{b=1}^B \hat{f}_b\right) = \sum_{b=1}^B \mathrm{Var}(\hat{f}_b) + \sum_{b \neq b'} \mathrm{Cov}(\hat{f}_b, \hat{f}_{b'}).

Since each f^b\hat{f}_b has variance ฯƒ2\sigma^2 and each pair has covariance ฯฯƒ2\rho \sigma^2:

=Bฯƒ2+B(Bโˆ’1)ฯฯƒ2.= B\sigma^2 + B(B-1)\rho\sigma^2.

Therefore:

Var(f^bag)=1B2[Bฯƒ2+B(Bโˆ’1)ฯฯƒ2]=ฯƒ2B+Bโˆ’1Bฯฯƒ2.\boxed{\mathrm{Var}(\hat{f}_{\text{bag}}) = \frac{1}{B^2}\left[B\sigma^2 + B(B-1)\rho\sigma^2\right] = \frac{\sigma^2}{B} + \frac{B-1}{B}\rho\sigma^2.}

You can rewrite this cleanly as:

Var(f^bag)=ฯฯƒ2+1โˆ’ฯBฯƒ2.\mathrm{Var}(\hat{f}_{\text{bag}}) = \rho\sigma^2 + \frac{1-\rho}{B}\sigma^2.

The first term is the irreducible correlated floor, and the second term decays with BB.


Part (b): As Bโ†’โˆžB \to \infty

Var(f^bag)โ†’Bโ†’โˆžฯฯƒ2.\mathrm{Var}(\hat{f}_{\text{bag}}) \xrightarrow{B\to\infty} \rho\sigma^2.

Interpretation:

  • If ฯ=0\rho = 0 (independent predictors): variance โ†’0\to 0. Perfect, unlimited reduction.
  • If ฯ=1\rho = 1 (perfectly correlated, e.g., identical bootstrap samples): variance โ†’ฯƒ2\to \sigma^2. No reduction at all.
  • In practice, bootstrap samples from the same dataset have high ฯ\rho, so bagging gives partial but limited variance reduction.

This is exactly why Random Forests inject extra randomness (random feature subsets) โ€” they lower ฯ\rho between trees, pushing the floor ฯฯƒ2\rho\sigma^2 down further.


Part (c): Bias Under Bagging

Compute the bias of f^bag\hat{f}_{\text{bag}}:

E[f^bag]=1Bโˆ‘b=1BE[f^b]=1Bโ‹…B(fโˆ—+ฮฒ)=fโˆ—+ฮฒ.E[\hat{f}_{\text{bag}}] = \frac{1}{B}\sum_{b=1}^B E[\hat{f}_b] = \frac{1}{B} \cdot B(f^* + \beta) = f^* + \beta.

Averaging does not change the bias. If each base learner is biased by ฮฒ\beta, the bag is also biased by ฮฒ\beta.

Fundamental limitation of bagging:

Bagging is a variance reduction technique only. It cannot fix a biased model.

This is why you should bag low-bias, high-variance models (like deep trees), not high-bias models (like shallow stumps). A pruned tree with high bias does not benefit from bagging โ€” its ensemble is still biased.


Summary Table

| Quantity | Single Learner | Bagged (Bโ†’โˆžB \to \infty) | |---|---|---| | Variance | ฯƒ2\sigma^2 | ฯฯƒ2\rho \sigma^2 | | Bias | ฮฒ\beta | ฮฒ\beta | | MSE | ฯƒ2+ฮฒ2\sigma^2 + \beta^2 | ฯฯƒ2+ฮฒ2\rho\sigma^2 + \beta^2 |

The elegant punchline: bagging attacks exactly one term of the bias-variance decomposition, and its power is limited by how correlated the bootstrap models are.

Source: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, 2nd ed., Section 8.7

Type: ML/StatsSource: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, 2nd ed., Section 8.7Edit on GitHub โ†—