Search

Search papers and lessons

Mallows Cp

Level 3 · 9 min read

Mallows' Cp scores a regression submodel by its residual sum of squares plus a penalty for its size, and a submodel with little bias has a Cp close to its number of parameters.

On this page

  • Colour = topic mix
  • Probability
  • Learning basics
  • Calculus
  • Linear algebra
  • Discrete math
  • Inference
  • Sign in to see your progress

TL;DR

When you have many candidate predictors, a regression that uses all of them fits the training data best but predicts new data poorly. Mallows' CpC_p is a score for a smaller model. It is the model's residual error, scaled, plus a penalty of two for each parameter. If a model leaves out nothing important, its CpC_p comes out close to its number of parameters pp. A CpC_p well above pp signals that the model is missing something real.

The examples use made-up numbers to show the arithmetic.

Where you'll see it: choosing which predictors to keep in a regression, reading the output of stepwise selection, and as the least-squares cousin of AIC.

Intuition

A ruler for fit and complexity

Suppose you are fitting a line to 20 points, and you could use one, two, or five predictors. More predictors always lower the residual sum of squares (RSS), the total squared gap between the data and the fit. Adding a predictor cannot make the training fit worse. So the RSS alone always says to add everything, and that is the trap that Overfitting sets.

The fix is to charge for complexity. CpC_p does this in a specific way: it divides the RSS by the noise variance, subtracts the number of observations nn (the value that cancels the RSS of a model with no bias, as the derivation below shows), and adds twice the number of parameters. The result is an estimate of how far the model's fitted values stray from the truth, in units of noise. A model that is too simple leaves out signal, so its RSS is too large. A model that is too complex has more parameters, and the 2p2p term pushes its score up.

The picture below shows the idea with illustrative curves. A submodel with no bias has CpC_p equal to pp. A submodel that leaves out a real effect has an extra term that is large when the model is small and shrinks as it grows.

246810024681012p, number of parametersC_p
  • no bias: C_p = p
  • bias term 4/p
Illustrative only. A submodel with no bias sits on the dashed line. A biased submodel sits above it, and the gap is largest for very small models.

Two more pieces of language help. The bias is the systematic part of the error that no choice of coefficients within the model can remove. The variance is the noise that comes from estimating coefficients from a finite sample. Adding predictors usually reduces bias and increases variance. CpC_p is a way to find the point where the two balance, in the terms set out in the Bias-Variance Tradeoff.

The math

Fit a least-squares model with pp parameters (including the intercept) to nn observations. Let RSSp\mathrm{RSS}_p be its residual sum of squares. Let σ^2\hat\sigma^2 be the estimate of the noise variance taken from the largest candidate model, which is assumed to be nearly unbiased. Mallows' CpC_p is

Cp=RSSpσ^2−n+2p.C_p = \frac{\mathrm{RSS}_p}{\hat\sigma^2} - n + 2p.

Here σ^2\hat\sigma^2 is the residual variance of the full model with pfullp_{\text{full}} parameters, σ^2=RSSfull/(n−pfull)\hat\sigma^2 = \mathrm{RSS}_{\text{full}} / (n - p_{\text{full}}).

Where the formula comes from

Write the true mean response as μ\boldsymbol\mu and the noise as independent with variance σ2\sigma^2. Let Hp\mathbf{H}_p be the projection (hat) matrix that maps y\mathbf{y} to the submodel's fitted values, projecting onto the span of its pp columns. A projection onto a pp-dimensional space has trace pp, and I−Hp\mathbf{I} - \mathbf{H}_p has trace n−pn - p. The residual vector is (I−Hp)y(\mathbf{I} - \mathbf{H}_p)\mathbf{y}, and its expected squared length is

E[RSSp]=σ2tr⁡(I−Hp)+∥(I−Hp)μ∥2=σ2(n−p)+Bp,\mathbb{E}[\mathrm{RSS}_p] = \sigma^2 \operatorname{tr}(\mathbf{I} - \mathbf{H}_p) + \lVert (\mathbf{I} - \mathbf{H}_p)\boldsymbol\mu \rVert^2 = \sigma^2 (n - p) + B_p,

where Bp=∥(I−Hp)μ∥2B_p = \lVert (\mathbf{I} - \mathbf{H}_p)\boldsymbol\mu \rVert^2 is the squared bias in the submodel. Divide by σ2\sigma^2 and take expectations of CpC_p, using σ^2≈σ2\hat\sigma^2 \approx \sigma^2:

E[Cp]≈σ2(n−p)+Bpσ2−n+2p=p+Bpσ2.\mathbb{E}[C_p] \approx \frac{\sigma^2(n-p) + B_p}{\sigma^2} - n + 2p = p + \frac{B_p}{\sigma^2}.

So CpC_p is near pp when the bias is zero, and it exceeds pp by the scaled bias otherwise. The same algebra shows that E∑i(y^i−μi)2=pσ2+Bp\mathbb{E}\sum_i (\hat y_i - \mu_i)^2 = p\sigma^2 + B_p, which is why CpC_p is described as an estimate of the scaled error in the fitted values.

Two facts that follow

  • For the full model, RSSfull/σ^2=n−pfull\mathrm{RSS}_{\text{full}}/\hat\sigma^2 = n - p_{\text{full}} exactly, so Cfull=pfullC_{\text{full}} = p_{\text{full}} by construction. Every candidate can be compared with the full model's pp.
  • CpC_p is minimised over subsets by searching many models. This is why Forward Stepwise Selection and similar searches use CpC_p as a stopping rule, and why Model Selection treats it as a penalised score.

Worked examples

Example
Scoring a subset of a 20-point regression

These numbers are made up for illustration.

  1. The full model has 5 predictors plus an intercept, so pfull=6p_{\text{full}} = 6 and n=20n = 20.
  2. Its residual sum of squares is RSSfull=40\mathrm{RSS}_{\text{full}} = 40, so σ^2=40/(20−6)=40/14≈2.857\hat\sigma^2 = 40 / (20 - 6) = 40 / 14 \approx 2.857.
  3. Take a submodel with p=3p = 3 (intercept plus two predictors) and RSS3=52\mathrm{RSS}_3 = 52.
  4. Scaled RSS: 52/2.857=52×14/40=18.252 / 2.857 = 52 \times 14 / 40 = 18.2.
  5. C3=18.2−20+2×3=4.2C_3 = 18.2 - 20 + 2 \times 3 = 4.2.

Interpretation: C3=4.2C_3 = 4.2 is a little above p=3p = 3, so the bias is small, about 1.21.2 in scaled units. The submodel is close to adequate.

Example
Choosing among a path of submodels

Continue with the same data. Here are three submodels with their RSS values, all fitted to the same 20 observations:

ModelppRSSScaled RSSCpC_p
Intercept and one predictor27526.2510.25
Intercept and two predictors35218.24.2
Intercept, three predictors44515.753.75
  1. The model with p=2p = 2 has C2=10.25C_2 = 10.25, far above 2. It leaves out a real effect.
  2. The model with p=3p = 3 has C3=4.2C_3 = 4.2, about 1.21.2 above its size.
  3. The model with p=4p = 4 has C4=15.75−20+8=3.75C_4 = 15.75 - 20 + 8 = 3.75, below its size. A value a little below pp is normal when noise pulls the RSS down by chance.
  4. Pick a small model whose CpC_p is close to pp. Here p=4p = 4 has the lowest CpC_p and sits just under its size, so it is the choice.

Interpretation: adding the third predictor lowers the RSS by 7 and so lowers the score. The score is what tells us whether that drop is worth its parameter. Here it is.

Tradeoffs and failure modes

CpC_p is simple, fast and tied to least squares. Its weaknesses come from the assumptions behind it.

SituationProblemBetter choice
The noise variance is estimated from a poor full modelσ^2\hat\sigma^2 is biased, so every CpC_p is offEstimate σ2\sigma^2 from a model you trust to have little bias, or use cross-validation
Many subsets are searchedThe minimum CpC_p is optimistic, and the chosen model overfitsValidate the choice on held-out data
The model is not linear least squaresThe formula does not applyUse AIC or cross-validation
The goal is prediction on new inputs, not fitted valuesCpC_p targets fitted values at the observed inputsUse Model Selection with held-out error
Predictors are highly correlatedSubsets change a lot with small data changes, and the path is unstableRegularise, for example with a ridge penalty

The 2p2p penalty is a choice. Other penalties, such as the one in BIC, give different answers and favour smaller models. CpC_p is in the same family as AIC: for least squares with known variance, the two rank models identically, which is why CpC_p is often called the regression-specific cousin of AIC.

History

Colin Mallows introduced CpC_p in the early 1970s as a practical way to choose subsets of regression variables from the residual sums of squares of candidate subsets. The problem it solved was concrete. Statisticians could already compute RSS for many subsets, but needed a rule that did not simply reward adding variables.

Akaike's information criterion, proposed at about the same time, rests on the same idea of an adjusted fit. CpC_p stayed popular in applied regression because it is easy to read off a regression printout and has a clear meaning: its value near pp indicates an adequate model.

Modern texts such as James, Witten, Hastie and Tibshirani's An Introduction to Statistical Learning present CpC_p alongside AIC and BIC, and use cross-validation for the same job, because cross-validation makes fewer assumptions.

Check yourself

QuestionRecall: what value of CpC_p suggests a submodel has little bias, and why?Show answer
A value close to pp, the number of parameters in the submodel. The expected value is p+Bp/σ2p + B_p/\sigma^2, where BpB_p is the squared bias, so zero bias gives CpC_p near pp.
QuestionComputation: n=25n = 25, σ^2=2\hat\sigma^2 = 2, and a submodel with p=4p = 4 has RSS4=60\mathrm{RSS}_4 = 60. What is C4C_4?Show answer
C4=60/2−25+2×4=30−25+8=13C_4 = 60 / 2 - 25 + 2 \times 4 = 30 - 25 + 8 = 13. This is far above 4, so the submodel is missing something real.
QuestionWhy: why does the RSS alone always favour the largest model, and what does the 2p2p term do about it?Show answer
Adding a predictor cannot increase the residual sum of squares, because least squares can always set the new coefficient to zero and keep the old fit. The 2p2p term charges each parameter, so an extra predictor must lower the scaled RSS by more than two to lower CpC_p.
QuestionApplied: a forward stepwise search gives CpC_p values of 12.0 at p=3p = 3, 6.1 at p=4p = 4, and 5.4 at p=5p = 5. Which model should you consider keeping, and what would you check before trusting it?Show answer
The p=5p = 5 model has the lowest CpC_p, at 5.4, which is close to its size of 5, so it looks adequate and is the natural candidate. Before trusting it, check it on held-out data, because the search over many subsets makes the minimum look better than it will perform on new data.

Sources