🧮 Brain Teaser

The Irrelevant Feature Paradox: When Adding Noise Helps OLS

Suppose you are fitting a linear model with OLS on a fixed design matrix XRn×pX \in \mathbb{R}^{n \times p}, where p<np < n, to predict y=Xβ+εy = X\beta^* + \varepsilon with εN(0,σ2I)\varepsilon \sim \mathcal{N}(0, \sigma^2 I).

Now consider adding qq pure noise features — columns ZRn×qZ \in \mathbb{R}^{n \times q} drawn independently of everything else — so your new design matrix is [XZ][X \mid Z], and you re-fit OLS on this expanded matrix.

Question: What happens to the expected in-sample (training) MSE as qq increases? Does it go up, go down, or stay the same? What about the expected out-of-sample (test) MSE on a new draw from the same distribution?

Give a crisp explanation of the paradox and what drives it.

overfittingbias-varianceOLSdegrees of freedomoptimism

Answer: The Irrelevant Feature Paradox: When Adding Noise Helps OLS

Key Idea / Intuition

OLS always fits the training data as well as possible given the degrees of freedom — adding more columns (even pure noise) can only decrease training error, because OLS is projecting yy onto a larger subspace, getting a tighter fit. But this comes at a cost: each noise column "uses up" a degree of freedom, inflating out-of-sample error. The gap between training MSE and test MSE grows with every noise column added. This is the optimism of training error made vivid.


Formal Proof / Solution

Setup

Let X~=[XZ]Rn×(p+q)\tilde{X} = [X \mid Z] \in \mathbb{R}^{n \times (p+q)}, and let y^=X~(X~X~)1X~y=Hy\hat{y} = \tilde{X}(\tilde{X}^\top \tilde{X})^{-1}\tilde{X}^\top y = H y be the OLS fit, where HH is the hat matrix (orthogonal projection onto the column space of X~\tilde{X}).

The hat matrix satisfies tr(H)=p+q\operatorname{tr}(H) = p + q (the number of columns, assuming full rank).


Training MSE

The in-sample residual sum of squares is:

RSS=yHy2=(IH)y2\text{RSS} = \|y - Hy\|^2 = \|(I-H)y\|^2

Since y=Xβ+εy = X\beta^* + \varepsilon and XβX\beta^* lies in the column space of X~\tilde{X} (since XX is a sub-block), we have (IH)Xβ=0(I-H)X\beta^* = 0, so:

RSS=(IH)ε2\text{RSS} = \|(I-H)\varepsilon\|^2

Taking expectations:

E[RSS]=σ2tr(IH)=σ2(npq)\mathbb{E}[\text{RSS}] = \sigma^2 \operatorname{tr}(I - H) = \sigma^2(n - p - q)

So the expected training MSE is:

E ⁣[RSSn]=σ2npqn\mathbb{E}\!\left[\frac{\text{RSS}}{n}\right] = \sigma^2 \cdot \frac{n - p - q}{n}

As qq increases, training MSE decreases — adding noise features always improves the apparent fit!


Test MSE (Out-of-Sample)

For a new observation y0=x0β+ε0y_0 = x_0^\top \beta^* + \varepsilon_0, the expected prediction error decomposes as:

EPE=Bias2+Variance+σ2\text{EPE} = \text{Bias}^2 + \text{Variance} + \sigma^2

The OLS estimator β^\hat{\beta} on X~\tilde{X} is unbiased for the true β\beta^* (with zeros for the noise columns), so Bias =0= 0. The variance of y^0\hat{y}_0 depends on how many columns are estimated. For simplicity, look at expected in-sample prediction error on a new yy drawn from the same XX:

E[Test MSE]=σ2n+p+qn\mathbb{E}[\text{Test MSE}] = \sigma^2 \cdot \frac{n + p + q}{n}

(This follows from the standard optimism formula: Test EPE=Training EPE+2σ2dn\text{Test EPE} = \text{Training EPE} + \frac{2\sigma^2 d}{n} where d=p+qd = p+q.)

As qq increases, test MSE increases — each noise column costs exactly 2σ2n\frac{2\sigma^2}{n} in optimism.


The Paradox Summarized

| Quantity | Formula | Direction as qq \uparrow | |---|---|---| | Expected Training MSE | σ2(npq)/n\sigma^2(n-p-q)/n | Decreases ↓ | | Expected Test MSE | σ2(n+p+q)/n\sigma^2(n+p+q)/n | Increases ↑ | | Optimism gap | 2σ2(p+q)/n2\sigma^2(p+q)/n | Widens ↑↑ |

The training error is a systematically biased estimator of true prediction error, and the bias grows linearly with the number of predictors — even useless ones. This is why model selection and regularization are essential: the model does not "know" its columns are noise.

Notably, at q=npq = n - p, the model would be exactly interpolating (RSS=0\text{RSS} = 0) — perfect training fit, terrible generalization. This is the classical overfitting catastrophe.

Source: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, Section 7.3–7.6

Type: ML/StatsSource: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, Section 7.3–7.6Edit on GitHub ↗