Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Optimism & Model Complexity

A covariance penalty estimates how much fitting to the observed responses reduces training error. The resulting degrees of freedom measure how strongly predictions respond to those responses.

Fresh Responses at the Same Inputs

For this page, condition on the design matrix XX. Let μi=m(Xi)\mu_i=m(X_i) and assume

E[Y∣X]=μ,Cov⁡(Y∣X)=σ2In.E[Y\mid X]=\mu,\qquad \operatorname{Cov}(Y\mid X)=\sigma^2I_n.

Let Yi0Y_i^0 be an independent new response generated at the same input XiX_i. With Y^i=f^T(Xi)\widehat Y_i=\widehat f_T(X_i), define

Err⁡in(T)=1n∑iE[(Yi0−Y^i)2∣T],err⁡train(T)=1n∑i(Yi−Y^i)2.\operatorname{Err}_{\mathrm{in}}(T)=\frac1n\sum_i E[(Y_i^0-\widehat Y_i)^2\mid T],\qquad \operatorname{err}_{\mathrm{train}}(T)=\frac1n\sum_i(Y_i-\widehat Y_i)^2.

“In-sample” here refers to the input locations, not reuse of the observed responses for scoring. This differs from random-input generalization error, which also averages over a new X0X_0.

The realized optimism is

op⁡(T)=Err⁡in(T)−err⁡train(T).\operatorname{op}(T)=\operatorname{Err}_{\mathrm{in}}(T)-\operatorname{err}_{\mathrm{train}}(T).

Averaging over response vectors YY at the fixed design gives the exact squared-error identity

ω(X)=EY∣X[op⁡(T)]=2n∑iCov⁡(Yi,Y^i∣X).\boxed{\omega(X)=E_{Y\mid X}[\operatorname{op}(T)] =\frac2n\sum_i\operatorname{Cov}(Y_i,\widehat Y_i\mid X).}
Derivation of the Covariance Penalty

For each ii, expand both squares:

E[(Yi0−Y^i)2∣X]−E[(Yi−Y^i)2∣X]=E[(Yi0)2−Yi2∣X]−2{E[Yi0Y^i∣X]−E[YiY^i∣X]}.\begin{aligned} &E[(Y_i^0-\widehat Y_i)^2\mid X]-E[(Y_i-\widehat Y_i)^2\mid X]\\ &=E[(Y_i^0)^2-Y_i^2\mid X] -2\{E[Y_i^0\widehat Y_i\mid X]-E[Y_i\widehat Y_i\mid X]\}. \end{aligned}

The second moments of Yi0Y_i^0 and YiY_i agree. Independence of Yi0Y_i^0 from the fitted rule gives E[Yi0Y^i∣X]=μiE[Y^i∣X]E[Y_i^0\widehat Y_i\mid X]=\mu_i E[\widehat Y_i\mid X]. Therefore the difference is

2{E[YiY^i∣X]−μiE[Y^i∣X]}=2Cov⁡(Yi,Y^i∣X).2\{E[Y_i\widehat Y_i\mid X]-\mu_i E[\widehat Y_i\mid X]\} =2\operatorname{Cov}(Y_i,\widehat Y_i\mid X).

Sum and divide by nn. Normal errors are not needed. The covariance identity itself also permits unequal response variances; the common-σ2\sigma^2 degrees-of-freedom normalization below uses homoscedasticity.

A model that closely follows each response tends to have a positive covariance penalty. This is why training error typically underestimates fresh-response error on average. Nonnegativity is not a theorem for every arbitrary prediction rule, and the identity above is not an exact correction for all random-input prediction problems.

Effective Degrees of Freedom

Define

df⁡(A;X)=1σ2∑iCov⁡(Yi,Y^i∣X).\boxed{\operatorname{df}(A;X)=\frac1{\sigma^2}\sum_i\operatorname{Cov}(Y_i,\widehat Y_i\mid X).}

Then

E[Err⁡in∣X]=E[err⁡train∣X]+2σ2ndf⁡(A;X).\boxed{E[\operatorname{Err}_{\mathrm{in}}\mid X] =E[\operatorname{err}_{\mathrm{train}}\mid X]+\frac{2\sigma^2}{n}\operatorname{df}(A;X).}

Degrees of freedom measure adaptivity to the observed responses. They need not be an integer or equal a count of displayed coefficients.

Linear Smoothers

If Y^=HY\widehat Y=HY and HH depends on XX and fixed tuning choices but not on YY, then

Cov⁡(Yi,Y^i∣X)=∑jHijCov⁡(Yi,Yj∣X)=σ2Hii,\operatorname{Cov}(Y_i,\widehat Y_i\mid X) =\sum_jH_{ij}\operatorname{Cov}(Y_i,Y_j\mid X)=\sigma^2H_{ii},

so

df⁡=tr⁡(H).\boxed{\operatorname{df}=\operatorname{tr}(H).}

Ordinary Least Squares

For a full-column-rank n×pn\times p design,

β^=(X⊤X)−1X⊤Y,H=X(X⊤X)−1X⊤.\widehat\beta=(X^\top X)^{-1}X^\top Y,\qquad H=X(X^\top X)^{-1}X^\top.

The hat matrix is a symmetric projection: H⊤=HH^\top=H, H2=HH^2=H. Its eigenvalues are 0 or 1, and

df⁡=tr⁡(H)=rank⁡(H)=p.\operatorname{df}=\operatorname{tr}(H)=\operatorname{rank}(H)=p.

Equivalently, cyclicity of trace gives tr⁡[(X⊤X)−1X⊤X]=p\operatorname{tr}[(X^\top X)^{-1}X^\top X]=p. With an intercept and dd independent predictor columns, p=d+1p=d+1. If columns are dependent, the projection has df rank⁡(X)\operatorname{rank}(X) and the displayed inverse must be replaced by an appropriate generalized inverse.

QuantityOLS valueRole
Fitted-model dfppComplexity of the fitted mean.
Residual dfn−pn-pDenominator in the usual unbiased error-variance estimate.
Expected optimism2σ2p/n2\sigma^2p/nTraining-to-fresh-response error correction.

Covariance Penalties & Mallows’ CpC_p

The general idea is to minimize

err⁡train+2n∑iCov⁡^(Yi,Y^i∣X).\operatorname{err}_{\mathrm{train}}+\frac2n\sum_i\widehat{\operatorname{Cov}}(Y_i,\widehat Y_i\mid X).

For OLS with fixed candidate models, a prediction-error-scale version of Mallows’ criterion is:

R^Cp=RSS⁡n+2σ^2pn.\widehat R_{C_p}=\frac{\operatorname{RSS}}n+\frac{2\widehat\sigma^2p}{n}.

A common dimensionless convention is

Cp=RSS⁡σ^2−n+2p,R^Cp=σ^2n(Cp+n).C_p=\frac{\operatorname{RSS}}{\widehat\sigma^2}-n+2p, \qquad \widehat R_{C_p}=\frac{\widehat\sigma^2}{n}(C_p+n).

These conventions rank candidates identically when they use the same observations and the same variance estimate. A common estimate is the residual mean square from an adequately specified larger model, provided it has residual degrees of freedom. A misspecified larger model can contaminate this estimate.

Akaike Information Criterion

Mallows’ criterion
AIC
R^Cp=RSS⁡n+2σ^2pn.\widehat R_{C_p}=\frac{\operatorname{RSS}}n+\frac{2\widehat\sigma^2p}{n}.

A squared-error correction using a common variance estimate across candidate models.

For a likelihood fitted by maximum likelihood, the conventional total-scale criterion is

AIC⁡=−2ℓ(θ^)+2q,\boxed{\operatorname{AIC}=-2\ell(\widehat\theta)+2q,}

where qq counts estimated likelihood parameters. An equivalent per-observation scaling is AIC⁡/n\operatorname{AIC}/n. Smaller values are preferred among comparable likelihoods fitted to the same response data. The usual AIC penalty is an asymptotic likelihood-based correction under regularity conditions.

Connection with CpC_p

For Gaussian regression with known common variance σ2\sigma^2, q=pq=p and

AIC⁡n=log⁡(2πσ2)+RSS⁡nσ2+2pn.\frac{\operatorname{AIC}}n =\log(2\pi\sigma^2)+\frac{\operatorname{RSS}}{n\sigma^2}+\frac{2p}{n}.

Apart from a common additive constant, this is R^Cp/σ2\widehat R_{C_p}/\sigma^2 when the variance in that score is σ2\sigma^2. Thus the criteria have the same ranking in this setting.

With unknown variance estimated separately by Gaussian maximum likelihood, σ^MLE2=RSS⁡/n\widehat\sigma^2_{\mathrm{MLE}}=\operatorname{RSS}/n and q=p+1q=p+1, giving

AIC⁡=nlog⁡(RSS⁡/n)+2(p+1)+constant.\operatorname{AIC}=n\log(\operatorname{RSS}/n)+2(p+1)+\text{constant}.

This is not literally the same formula as the common-variance CpC_p score. Keep the scaling, variance treatment, and parameter count explicit when comparing formulas.

Covariance penalties are convenient when complexity can be calculated. Cross-validation replaces that calculation with repeated held-out fitting and can be applied to much broader learning procedures.