Sam Babichenko

Reading notes / Benign overfitting

Stein's paradox and the James-Stein estimator

Stein, 1956; James and Stein, 1961; Efron and Morris, 1973

Context. Observe X∼Nd(θ,Id)X\sim N_d(\theta,I_d) and estimate θ\theta under total squared error. The MLE XX is unbiased, minimax with constant risk dd, and admissible for d=1d=1, and with independent coordinates everyone expected the same for all dd. Stein (1956) proved that for d≥3d\ge3 some estimator has smaller risk at every θ\theta; James and Stein (1961) gave the explicit rule and its exact risk; Efron and Morris (1973) read it as a Bayes rule whose prior variance is estimated from the data. The reason is that in many dimensions the noise adds to the observation's length on average, E∥X∥2=∥θ∥2+d\mathbb E\|X\|^2=\|\theta\|^2+d, so XX systematically overshoots θ\theta in length. Pulling it toward any fixed point by an amount estimated from ∥X∥2\|X\|^2 lowers the risk by up to d−2d-2, and the error from estimating that one number stays bounded (the risk at the target is 22).

Setting. X∼Nd(θ,σ2Id)X\sim N_d(\theta,\sigma^2I_d), σ=1\sigma=1 unless stated, risk R(θ,δ)=Eθ∥δ(X)−θ∥2R(\theta,\delta)=\mathbb E_\theta\|\delta(X)-\theta\|^2, S=∥X∥2S=\|X\|^2, and K∼Poisson(∥θ∥2/2)K\sim\mathrm{Poisson}(\|\theta\|^2/2), so that S∣K∼χd+2K2S\mid K\sim\chi^2_{d+2K}. A rule is inadmissible if another has risk no larger at every θ\theta and smaller at some.

Theorem 1 (Stein 1956). Let d≥3d\ge3 and δa,b(X)=(1−ba+∥X∥2)X\delta_{a,b}(X)=\big(1-\frac{b}{a+\|X\|^2}\big)X with a,b>0a,b>0. Uniformly in θ\theta as a→∞a\to\infty, R(θ,δa,b)≤d−2b(d−2)−b2a+∥θ∥2+o(1a+∥θ∥2),R(\theta,\delta_{a,b})\le d-\frac{2b(d-2)-b^2}{a+\|\theta\|^2}+o\Big(\frac1{a+\|\theta\|^2}\Big), so for 0<b<2(d−2)0\lt b\lt 2(d-2) and aa large enough R(θ,δa,b)<dR(\theta,\delta_{a,b})\lt d for every θ\theta, and XX is inadmissible. With b=d−2b=d-2 the saving is asymptotic to (d−2)2/∥θ∥2(d-2)^2/\|\theta\|^2 as ∥θ∥→∞\|\theta\|\to\infty, and this is best possible: no estimator has R(θ,δ)≤d−c/∥θ∥2R(\theta,\delta)\le d-c/\|\theta\|^2 for all large ∥θ∥\|\theta\| with c>(d−2)2c\gt(d-2)^2. For d=2d=2, XX is admissible.

Theorem 2 (James and Stein 1961). For d≥3d\ge3 and any real bb, R(θ,(1−bS)X)=d−[2b(d−2)−b2] E1d−2+2K.R\Big(\theta,\big(1-\tfrac{b}{S}\big)X\Big)=d-\big[2b(d-2)-b^2\big]\,\mathbb E\frac{1}{d-2+2K}. The bracket is maximized by b=d−2b=d-2 at every θ\theta: θ^JS=(1−d−2S)X\hat\theta^{JS}=\big(1-\frac{d-2}{S}\big)X with risk d−(d−2)2 E1d−2+2K<dd-(d-2)^2\,\mathbb E\frac{1}{d-2+2K}\lt d, equal to 22 at θ=0\theta=0 and increasing in ∥θ∥\|\theta\| to dd. With unknown variance and an independent Se∼σ2χn2S_e\sim\sigma^2\chi^2_n, the rule (1−d−2n+2Se∥X∥2)X\big(1-\frac{d-2}{n+2}\frac{S_e}{\|X\|^2}\big)X is optimal in its class and keeps the fraction n/(n+2)n/(n+2) of the saving.

Theorem 3 (SURE and the positive part). If δ(X)=X+g(X)\delta(X)=X+g(X) with gg weakly differentiable and Eθ∑i∣∂igi∣<∞\mathbb E_\theta\sum_i|\partial_ig_i|\lt\infty, then R(θ,δ)=Eθ[d+∥g∥2+2∇ ⁣⋅g]R(\theta,\delta)=\mathbb E_\theta\big[d+\|g\|^2+2\nabla\!\cdot g\big], an unbiased risk estimate that does not involve θ\theta; for θ^JS\hat\theta^{JS} it is d−(d−2)2/Sd-(d-2)^2/S (Stein 1981; Efron's short proof that θ^JS\hat\theta^{JS} dominates XX). The positive part θ^JS+=(1−d−2S)+X\hat\theta^{JS+}=\big(1-\frac{d-2}{S}\big)_+X strictly dominates θ^JS\hat\theta^{JS}, and generally (1−c(S))+X(1-c(S))_+X strictly dominates (1−c(S))X(1-c(S))X whenever Pθ(c(S)>1)>0P_\theta(c(S)\gt1)\gt0. It is itself inadmissible (it is not smooth, while admissible rules here are generalized Bayes and hence analytic), but the possible further gains are small.

Theorem 4 (empirical Bayes; Efron and Morris 1973). Under θi∼iidN(0,A)\theta_i\stackrel{iid}{\sim}N(0,A) the Bayes rule is (1−B)X(1-B)X with B=1/(1+A)B=1/(1+A), and θ^JS\hat\theta^{JS} is that rule with BB replaced by an unbiased estimate. The Bayes risks are RABayes=dAA+1,RAJS=dAA+1+2A+1,RAMLE=d,R^{Bayes}_A=\frac{dA}{A+1},\qquad R^{JS}_A=\frac{dA}{A+1}+\frac{2}{A+1},\qquad R^{MLE}_A=d, so James-Stein gives up the share 2/d2/d of the attainable saving (the relative savings loss) at every AA. With the prior mean unknown, Lindley's rule θ^i=Xˉ+(1−d−3∑j(Xj−Xˉ)2)(Xi−Xˉ)\hat\theta_i=\bar X+\big(1-\frac{d-3}{\sum_j(X_j-\bar X)^2}\big)(X_i-\bar X) dominates XX for d≥4d\ge4; toward a fitted rr-parameter regression the constant is d−r−2d-r-2.

Step 1

∥X∥2\|X\|^2 overestimates ∥θ∥2\|\theta\|^2 by about dd, and the best shrinkage factor is 1−d/∥X∥21-d/\|X\|^2 (Stein's heuristic). Since ∥X∥2=d+∥θ∥2+Op(d+∥θ∥2)\|X\|^2=d+\|\theta\|^2+O_p(\sqrt{d+\|\theta\|^2}), the data reveal ∥θ∥2\|\theta\|^2 up to an error small next to d+∥θ∥2d+\|\theta\|^2. Try δ=[1−h]X\delta=[1-h]X with hh a function of ∥X∥2/d≈1+ρ2\|X\|^2/d\approx1+\rho^2, ρ2=∥θ∥2/d\rho^2=\|\theta\|^2/d: ∥δ−θ∥2=d[(1−h)2+ρ2h2]+Op(d),\|\delta-\theta\|^2=d\big[(1-h)^2+\rho^2h^2\big]+O_p(\sqrt d), minimized at h=1/(1+ρ2)h=1/(1+\rho^2), that is δ=(1−d/∥X∥2)X\delta=(1-d/\|X\|^2)X, with loss about dρ2/(1+ρ2)d\rho^2/(1+\rho^2), the Bayes risk of Theorem 4 at A=ρ2A=\rho^2. This shrinks more than rescaling onto the sphere of radius ∥θ∥\|\theta\| because the noise also points XX in a wrong direction, and shrinking past the sphere removes more of that error than it adds in bias.

Step 2

A small bounded shrinkage already beats XX (Stein 1956). With Y=X−θY=X-\theta, expanding the square gives R(θ,δa,b)≤d−2b EY⊤(Y+θ)−b/2a+∥Y+θ∥2.R(\theta,\delta_{a,b})\le d-2b\,\mathbb E\frac{Y^\top(Y+\theta)-b/2}{a+\|Y+\theta\|^2}. Expand the denominator to second order in θ⊤Y\theta^\top Y and use rotational invariance (given ∥Y∥2\|Y\|^2, θ⊤Y\theta^\top Y has mean 00 and second moment ∥θ∥2∥Y∥2/d\|\theta\|^2\|Y\|^2/d); the leading terms give (d−2−b/2)/(a+∥θ∥2)(d-2-b/2)/(a+\|\theta\|^2), the bound of Theorem 1. The remainder is negligible uniformly only because a→∞a\to\infty (Stein's bounds, from a Chebyshev bound on {θ⊤Y<−∥θ∥2/4}\{\theta^\top Y\lt-\|\theta\|^2/4\} when ∥θ∥2>a\|\theta\|^2\gt a, are of order 1/((a+∥θ∥2)a)1/((a+\|\theta\|^2)a) and (a+∥θ∥2)−3/2(a+\|\theta\|^2)^{-3/2}), so aa serves only to keep the expansion uniform, and Step 3 does without it.

Step 3

Stein's lemma gives the exact risk of (1−b/S)X(1-b/S)X in terms of Eθ[1/S]\mathbb E_\theta[1/S] (SURE). Gaussian integration by parts, E[(Xi−θi)gi(X)]=E[∂igi(X)]\mathbb E[(X_i-\theta_i)g_i(X)]=\mathbb E[\partial_ig_i(X)], converts the cross term of ∥X+g−θ∥2\|X+g-\theta\|^2 into an expected divergence, which is SURE. For g=−bX/Sg=-bX/S, ∇ ⁣⋅g=−b(d−2)/S\nabla\!\cdot g=-b(d-2)/S, so R(θ,(1−bS)X)=d−[2b(d−2)−b2] Eθ1S,R\Big(\theta,\big(1-\tfrac bS\big)X\Big)=d-\big[2b(d-2)-b^2\big]\,\mathbb E_\theta\frac1S, and E[1/S]\mathbb E[1/S] is finite exactly when d≥3d\ge3. Since θ\theta enters only through one positive factor, the rule beats XX iff 0<b<2(d−2)0\lt b\lt2(d-2), and b=d−2b=d-2 is best at every θ\theta at once, with no expansion in aa.

Step 4

The exact risk is a Poisson mixture (James and Stein 1961). Both terms reduce to E[1/(d−2+2K)]\mathbb E[1/(d-2+2K)] through S∣K∼χd+2K2S\mid K\sim\chi^2_{d+2K} and E[1/χm2]=1/(m−2)\mathbb E[1/\chi^2_m]=1/(m-2); without Stein's lemma, James and Stein got the cross term E[(X−θ)⊤X/S]\mathbb E[(X-\theta)^\top X/S] from a power series integrated termwise against Beta integrals. The risk is 22 at θ=0\theta=0, increases in ∥θ∥\|\theta\| because KK is stochastically increasing, and by Jensen is at most 2+(d−2)∥θ∥2d−2+∥θ∥22+\frac{(d-2)\|\theta\|^2}{d-2+\|\theta\|^2}, close to the oracle of Step 1. The whole saving is made along XX: every rule c(X)Xc(X)X has the same error orthogonal to XX, while the mean square error along XX is 1+(d−2)E1d−2+2K≤21+(d-2)\mathbb E\frac{1}{d-2+2K}\le2 for James-Stein. Conditioning on SeS_e and using its first two moments gives the unknown-variance risk σ2{d−[2an(d−2)−a2n(n+2)] E1d−2+2K}\sigma^2\{d-[2an(d-2)-a^2n(n+2)]\,\mathbb E\frac{1}{d-2+2K}\}, now with K∼Poisson(∥θ∥2/2σ2)K\sim\mathrm{Poisson}(\|\theta\|^2/2\sigma^2), for the factor 1−aSe/∥X∥21-aS_e/\|X\|^2, optimized at a=(d−2)/(n+2)a=(d-2)/(n+2).

Step 5

(d−2)2/∥θ∥2(d-2)^2/\|\theta\|^2 is the best rate, and XX is admissible for d=2d=2 (Stein 1956). Averaging a rule over O(d)O(d) with Haar measure gives a spherically symmetric rule whose risk at θ\theta, by convexity of the loss, is at most the original risk averaged over the sphere of radius ∥θ∥\|\theta\|, so it keeps any bound R≤d−c/∥θ∥2R\le d-c/\|\theta\|^2; and for those the information inequality yields a differential inequality with no solution. For bias −φ(t)θ-\varphi(t)\theta, t=∥θ∥2t=\|\theta\|^2, Cramér-Rao with the gradient-squared term dropped gives R(θ)≥d+tφ2−2dφ−4tφ′.R(\theta)\ge d+t\varphi^2-2d\varphi-4t\varphi'. For d=2d=2, R≤2R\le2 forces ψ′≥ψ2/4t\psi'\ge\psi^2/4t for ψ=tφ\psi=t\varphi, so 1/ψ1/\psi would have to change by 14∣log⁡(t/t0)∣\frac14|\log(t/t_0)| toward 00 or ∞\infty while ψ\psi is monotone and keeps its sign; hence ψ≡0\psi\equiv0, so δ\delta is unbiased and R≥2R\ge2. For d≥3d\ge3, assume a saving c/tc/t with α2=c−(d−2)2>0\alpha^2=c-(d-2)^2\gt0 and center at the James-Stein bias, φ=(d−2)/t+f\varphi=(d-2)/t+f; the 1/t1/t terms collapse to −(d−2)2/t-(d-2)^2/t, and with ψ=tf\psi=tf 4ψ′≥α2+ψ2t⟹4α[arctan⁡ψ(t)α−arctan⁡ψ(t0)α]≥log⁡tt0,4\psi'\ge\frac{\alpha^2+\psi^2}{t}\quad\Longrightarrow\quad\frac4\alpha\Big[\arctan\frac{\psi(t)}\alpha-\arctan\frac{\psi(t_0)}\alpha\Big]\ge\log\frac t{t_0}, impossible for large tt because the left side is at most 4π/α4\pi/\alpha.

Step 6

Truncating the shrinkage factor at zero lowers the risk (positive part). When c=(d−2)/S>1c=(d-2)/S\gt1, James-Stein flips the sign of XX, and replacing it by 00 lowers the loss by (c−1)2S+2(c−1) θ⊤X(c-1)^2S+2(c-1)\,\theta^\top X. The first term is positive. For the second, E θ⊤X=∥θ∥2\mathbb E\,\theta^\top X=\|\theta\|^2 is not enough because c−1c-1 is correlated with θ⊤X\theta^\top X, so condition on SS, which fixes cc: on the sphere ∥x∥2=S\|x\|^2=S the density of XX is proportional to eθ⊤xe^{\theta^\top x}, and reflecting across θ⊥\theta^\perp pairs ±θ⊤x\pm\theta^\top x with weights e±θ⊤xe^{\pm\theta^\top x}, so E[θ⊤X∣S]≥0\mathbb E[\theta^\top X\mid S]\ge0. Nothing used the form of cc, which gives the general statement.

Step 7

James-Stein is the Bayes rule with its one unknown estimated (Efron and Morris 1973). Marginally X∼Nd(0,(1+A)I)X\sim N_d(0,(1+A)I), so S∼(1+A)χd2S\sim(1+A)\chi^2_d and Ed−2S=d−21+A E1χd2=B.\mathbb E\frac{d-2}{S}=\frac{d-2}{1+A}\,\mathbb E\frac1{\chi^2_d}=B. Averaging SURE over the marginal shows that the Bayes risk of James-Stein exceeds that of the Bayes rule by 2B2B, against dBdB for the MLE, whence 2/d2/d. Estimating the prior mean by Xˉ\bar X leaves ∑i(Xi−Xˉ)2∼(1+A)χd−12\sum_i(X_i-\bar X)^2\sim(1+A)\chi^2_{d-1}, so each estimated location parameter removes one degree of freedom. The MLE of BB, min⁡(1,d/S)\min(1,d/S), gives (1−d/S)+X(1-d/S)_+X; its untruncated form dominates XX for d≥5d\ge5 but by Step 3 has uniformly larger risk than θ^JS\hat\theta^{JS}. The prior only suggests the rule; domination holds at every fixed θ\theta.

Consequences. Partial pooling. The posterior mean M+(1−B)(Xi−M)M+(1-B)(X_i-M) under θi∼N(M,A)\theta_i\sim N(M,A) is the partial-pooling estimate of multilevel models; Lindley-James-Stein estimates MM and BB from the spread of the XiX_i and beats no pooling at every configuration of the θi\theta_i once d≥4d\ge4, exchangeable or not; in Efron's batting-average example it reduces total prediction error to 0.28 of the MLE's. Implicit regularization. With orthonormal design, ridge with penalty λ\lambda is the Bayes rule with A=σ2/λA=\sigma^2/\lambda, so James-Stein is ridge with λ\lambda tuned on the data. Early stopping, weight decay and minimum-norm solutions also bias toward a fixed point, and Stein's result is the cleanest proof that such a bias, with the amount tuned on the data, can lower total error at every parameter value once d≥3d\ge3. Limits. The gain is in total squared error only, and single coordinates can lose badly (in Efron's simulation an outlying mean's error rises from 1.08 to 2.04). It is concentrated near the target, vanishing relative to dd as ∥θ∥2/d→∞\|\theta\|^2/d\to\infty. It needs d≥3d\ge3 and Gaussian noise with known or independently estimated variance (James and Stein state without proof a bounded-shrinkage version under finite fourth moments, with b<2(d−2)min⁡iσi2b\lt2(d-2)\min_i\sigma_i^2 and aa not made explicit). Naive plug-in intervals undercover.

Terms

θ^JS\hat\theta^{JS}
(1−d−2∥X∥2)X\big(1-\frac{d-2}{\|X\|^2}\big)X; risk d−(d−2)2 E1d−2+2Kd-(d-2)^2\,\mathbb E\frac1{d-2+2K}, equal to 2 at θ=0\theta=0.
θ^JS+\hat\theta^{JS+}
(1−d−2∥X∥2)+X\big(1-\frac{d-2}{\|X\|^2}\big)_+X; strictly dominates θ^JS\hat\theta^{JS}, itself inadmissible.
Stein's lemma
E[(Xi−θi)gi(X)]=E[∂igi(X)]\mathbb E[(X_i-\theta_i)g_i(X)]=\mathbb E[\partial_ig_i(X)] for X∼N(θ,I)X\sim N(\theta,I): Gaussian integration by parts.
SURE
d+∥g∥2+2∇ ⁣⋅gd+\|g\|^2+2\nabla\!\cdot g, unbiased for the risk of X+g(X)X+g(X); for JS it is d−(d−2)2/Sd-(d-2)^2/S.
(1−b/S)X(1-b/S)X
Risk d−[2b(d−2)−b2] E[1/S]d-[2b(d-2)-b^2]\,\mathbb E[1/S]; dominates XX iff 0<b<2(d−2)0\lt b\lt2(d-2), best b=d−2b=d-2.
Shrinkage factor BB
1/(1+A)1/(1+A) under θi∼N(0,A)\theta_i\sim N(0,A); Bayes rule (1−B)X(1-B)X; (d−2)/S(d-2)/S is unbiased for BB.
Relative savings loss
(RAJS−RABayes)/(RAMLE−RABayes)=2/d(R^{JS}_A-R^{Bayes}_A)/(R^{MLE}_A-R^{Bayes}_A)=2/d for every AA.
Lindley rule
Shrink toward Xˉ\bar X with d−3d-3 in place of d−2d-2; dominates for d≥4d\ge4; d−r−2d-r-2 for an rr-parameter target.
Unknown σ2\sigma^2
(1−d−2n+2Se∥X∥2)X\big(1-\frac{d-2}{n+2}\frac{S_e}{\|X\|^2}\big)X, Se∼σ2χn2S_e\sim\sigma^2\chi^2_n; keeps the fraction n/(n+2)n/(n+2) of the saving.
Stein's optimal rate
No rule saves at least c/∥θ∥2c/\|\theta\|^2 with c>(d−2)2c\gt(d-2)^2 for all large ∥θ∥\|\theta\| (information inequality).

Quiz

  1. Why does the James-Stein argument fail for d≤2d\le2?
  2. What did Stein's lemma replace in James and Stein's 1961 computation of the exact risk?
  3. In Stein's information-inequality argument for d≥3d\ge3, what does writing the bias coefficient as φ=(d−2)/t+f\varphi=(d-2)/t+f accomplish?
  4. Geometrically, where does James-Stein gain over XX?

Sources