Tutorials › Regression Analysis (Undergraduate) › Deriving Mallows Cp as a Prediction-Error Estimate

Information Criteria and Model Comparison · Tutorial 633 of 991

Deriving Mallows Cp as a Prediction-Error Estimate

See how Cp estimates a model’s scaled prediction error, and why its variance calibration comes from a fuller model.

Advanced 9 min read

What You'll Learn

  • Define prediction error for fitted mean responses at the observed design points.
  • Derive the expected squared error of a least-squares fit using projection matrices.
  • Show how the residual sum of squares and a model-size penalty combine to form Cp.
  • Explain why a fuller model can provide an estimate of the common error variance.
  • Distinguish the exact result when the variance is known from the plug-in Cp used in practice.
  • Recognize how lack of fit in the fuller model can weaken Cp’s variance calibration.

Why Cp Has a Fit Term and a Penalty

A regression model with more predictors can fit the observed responses at least as well as a smaller model, because adding predictors cannot increase the least-squares residual sum of squares. But a smaller residual sum of squares alone does not show that the model will estimate the underlying mean responses well: fitting extra noise can make its fitted values less reliable. Mallows’ \(C_p\) combines a measure of fit with a penalty for the number of fitted parameters.

The rationale can be derived by asking a precise question: across repeated samples with the same predictor values, what is the expected squared distance between a model’s fitted mean responses and the true mean responses? The derivation explains both the form of \(C_p\) and why it needs an estimate of the error variance from a fuller model.

Setup and Prediction-Error Target

Suppose there are \(n\) observations with fixed predictor values. Write the response vector as \(y=\mu+\varepsilon\), where \(\mu\) is the vector of true mean responses at those predictor values and \(\varepsilon\) is the vector of errors. Assume the errors have mean zero, common variance \(\sigma^2\), and are independent. Normality is not needed for the expectation calculation below. Assume each candidate regression model is fit by least squares, has \(k\) identifiable parameters, and includes an intercept when appropriate.

For a candidate model with design matrix \(X_m\), let \(H_m=X_m(X_m^\mathsf{T}X_m)^{-1}X_m^\mathsf{T}\) be its projection matrix, assuming the columns are linearly independent. The fitted response vector is \(\hat{\mu}_m=H_my\). Its residual sum of squares is \(RSS_m=\|y-\hat{\mu}_m\|^2\). The parameter count \(k\) includes the intercept if the model has one.

Definition: Here the squared prediction error for a fitted model means the squared distance from its fitted mean responses to the true mean responses at the fixed predictor values: \(PE_m=\|\hat{\mu}_m-\mu\|^2\). Its expectation is taken over repeated error vectors at those same predictor values. Predicting future observed responses adds their error variance to this target; that distinction is described below.

The model need not represent the true mean vector exactly. Define its lack-of-fit vector as \(\delta_m=(I-H_m)\mu\). The length squared \(\|\delta_m\|^2\) measures the part of the true mean vector that the candidate model cannot represent. It is zero when \(\mu\) lies in the model’s column space.

Deriving the Prediction-Error Identity

The least-squares fitted means are \(H_my=H_m\mu+H_m\varepsilon\). Subtracting the true means gives \(H_m\mu-\mu+H_m\varepsilon=-\delta_m+H_m\varepsilon\). Squaring and taking expectations separates systematic lack of fit from random estimation error: the cross-product has expectation zero because \(E(\varepsilon)=0\).

$$ \begin{aligned} E(PE_m) &=E\left[\|-\delta_m+H_m\varepsilon\|^2\right]\\ &=\|\delta_m\|^2+E\left[\varepsilon^\mathsf{T}H_m^\mathsf{T}H_m\varepsilon\right]\\ &=\|\delta_m\|^2+\sigma^2\operatorname{tr}(H_m)\\ &=\|\delta_m\|^2+k\sigma^2. \end{aligned} $$

For the third line, \(H_m\) is a symmetric projection matrix, so \(H_m^\mathsf{T}H_m=H_m\). The error covariance matrix is \(\sigma^2I\), which gives \(E(\varepsilon^\mathsf{T}H_m\varepsilon)=\sigma^2\operatorname{tr}(H_m)\). A projection onto a \(k\)-dimensional model space has trace \(k\). Thus the expected squared error consists of squared lack of fit plus a variance contribution of \(k\sigma^2\).

The residuals are \((I-H_m)y\). Since \((I-H_m)H_m=0\), their systematic component is \(\delta_m\); their random component lies in the residual space, whose dimension is \(n-k\). Therefore their expected squared length is

$$ E(RSS_m)=\|\delta_m\|^2+(n-k)\sigma^2. $$

Subtracting this expected residual sum of squares from the expected prediction error shows what correction is needed to turn fit into an estimate of prediction error:

$$ \begin{aligned} E(PE_m) &=E(RSS_m)+2k\sigma^2-n\sigma^2. \end{aligned} $$
Theorem: If \(\sigma^2\) is known, then \((RSS_m/\sigma^2)-n+2k\) is an unbiased estimate of \(E(PE_m)/\sigma^2\). This quantity is the known-variance form of Mallows’ \(C_p\). Its \(2k\) term corrects for the optimism of judging a model using the same responses used to fit it.

Worked Examples of the Derivation

Worked Example: Separating Lack of Fit from Estimation Variance

Consider a hypothetical fixed design with \(n=8\) observations. A candidate model has \(k=2\) parameters, the error variance is \(\sigma^2=4\), and its lack-of-fit vector has squared length \(\|\delta_m\|^2=12\). Find the expected prediction error and verify the Cp identity using the expected residual sum of squares.

The prediction-error formula gives

$$ E(PE_m)=\|\delta_m\|^2+k\sigma^2=12+2(4)=20. $$

The model leaves \(n-k=8-2=6\) residual dimensions. Its expected residual sum of squares is

$$ E(RSS_m)=\|\delta_m\|^2+(n-k)\sigma^2=12+6(4)=36. $$

Applying the correction gives \(E(RSS_m)+2k\sigma^2-n\sigma^2=36+2(2)(4)-8(4)=36+16-32=20\), matching the expected prediction error. Dividing by the known variance, the expected scaled error is \(20/4=5\); equivalently, \(36/4-8+2(2)=9-8+4=5\). This illustrates why the correction is tied to the parameter count, not to an arbitrary preference for small models.

Worked Example: Calculating Cp with a Fuller-Model Variance Estimate

Suppose a hypothetical analysis has \(n=12\) observations. A fuller model has \(k_F=5\) parameters and \(RSS_F=28\). A candidate model has \(k=2\) parameters and \(RSS_m=52\). Assume the fuller model contains the true mean structure and the usual common-variance assumptions hold. Calculate the residual variance estimate and the candidate’s plug-in \(C_p\).

The fuller model has \(12-5=7\) residual degrees of freedom, so its residual mean square is

$$ \hat{\sigma}^2_F=\frac{RSS_F}{n-k_F}=\frac{28}{12-5}=4. $$

Substitute this variance estimate into the known-variance expression:

$$ \widehat{C}_{p,m} =\frac{RSS_m}{\hat{\sigma}^2_F}-n+2k =\frac{52}{4}-12+2(2) =13-12+4=5. $$

The value \(5\) is a plug-in estimate of the candidate model’s expected squared error for fitted mean responses, scaled by the error variance. It is not a prediction error measured in squared response units; multiplying by the variance estimate gives the corresponding scale, \(5(4)=20\) squared response units. The calculation does not establish that the candidate model is adequate; it gives a criterion for comparing candidate fits under the stated assumptions.

Why the Variance Estimate Comes from a Fuller Model

The identity uses the common error variance \(\sigma^2\), which is usually unknown. A fuller model is used to estimate it because, if that model contains the true mean vector and has \(k_F\) parameters, its lack-of-fit vector is zero. Its residual sum of squares then has expectation \((n-k_F)\sigma^2\), so

$$ \hat{\sigma}^2_F=\frac{RSS_F}{n-k_F} $$

is an unbiased estimator of \(\sigma^2\). Using this estimate in place of \(\sigma^2\) produces the commonly reported plug-in criterion \(\widehat{C}_{p,m}=RSS_m/\hat{\sigma}^2_F-n+2k\). Because the variance estimate is itself random, this substitution does not make the resulting ratio an exact unbiased estimator in every finite sample. The derivation gives the exact expectation rationale when the variance is known; the practical criterion uses the fuller-model estimate to calibrate it.

A fuller model does not automatically provide a good variance estimate. If even that model misses part of the true mean structure, then \(E(RSS_F)=\|\delta_F\|^2+(n-k_F)\sigma^2\). Dividing by its residual degrees of freedom includes the extra term \(\|\delta_F\|^2/(n-k_F)\), so the estimate tends to be too large. Cp’s calibration therefore relies on the fuller model being a plausible description of the mean structure, as well as on a common error variance.

Worked Example: Why the Fuller Model Matters for Calibration

In a hypothetical data set, \(n=10\). A fuller model has \(k_F=4\) and \(RSS_F=24\). A smaller candidate has \(k=2\) and \(RSS_m=36\). First use the fuller model to estimate the common error variance, then compare the result with the value obtained by improperly using the candidate model’s own residual mean square.

The fuller model leaves \(10-4=6\) residual degrees of freedom, giving \(\hat{\sigma}^2_F=24/6=4\). Its calibrated criterion is

$$ \widehat{C}_{p,m}=\frac{36}{4}-10+2(2)=9-10+4=3. $$

The candidate model’s own residual mean square is \(36/(10-2)=36/8=4.5\). If that value is substituted instead, the calculation becomes \(36/4.5-10+4=8-10+4=2\). That is a different result because the candidate’s residual sum of squares can include both random error and lack of fit; it is not the intended independent calibration of the common error level. Under the assumption that the fuller model captures the true mean structure, the fuller-model estimate is the appropriate one for this Cp calculation.

Mean-Response Error and Future Responses

The derivation targeted error in estimating the vector of true mean responses. If the goal is instead to predict a new vector of responses at the same predictor values, write \(y^*=\mu+\varepsilon^*\), where the new errors have mean zero, variance \(\sigma^2\), and are independent of the errors used to fit the model. Then

$$ E\left(\|\hat{\mu}_m-y^*\|^2\right) =E(PE_m)+n\sigma^2. $$

The extra term is the irreducible error in the future observations. For models evaluated on the same \(n\) design points with the same error variance, it is common to all candidates. Thus Cp’s model comparison targets can be described as estimation error for the mean responses or, after adding that common term, expected error for future responses. The distinction matters for interpretation, but not for ranking those candidates by the criterion.

Common Mistakes and Practical Meaning

  • Using residual sum of squares alone. A smaller model’s larger residual sum of squares does not by itself mean it predicts worse. Cp adds \(2k\hat{\sigma}^2_F\) to account for estimation variance and subtracts the common \(n\hat{\sigma}^2_F\) term.
  • Counting only predictors. The \(k\) in the formula counts fitted parameters, including an intercept when present. The criterion’s penalty depends on the model’s dimension.
  • Treating estimated Cp as an exact unbiased result. The exact expectation identity uses the true \(\sigma^2\). Replacing it with a fuller-model estimate is a practical plug-in step, with uncertainty of its own.
  • Assuming any fuller model gives a valid variance estimate. If the fuller model has substantial lack of fit, its residual mean square can be inflated and the resulting Cp calibration can be misleading.

The derivation gives Cp a clear purpose: it estimates scaled prediction error by correcting residual fit for the fact that fitted values have been adjusted to the observed data. It does not guarantee that the best-ranked candidate is true, nor does it remove the need to check whether the regression assumptions and fuller-model variance estimate are reasonable.

Check Your Understanding

Use the definitions and derivation above to answer these questions.

  1. In the prediction-error derivation, what do the two terms \(\|\delta_m\|^2\) and \(k\sigma^2\) represent?
  2. For \(n=15\), \(k=3\), \(\sigma^2=2\), and \(\|\delta_m\|^2=6\), calculate \(E(PE_m)\) and \(E(RSS_m)\). Verify that the Cp identity gives the same expected prediction error.
  3. Why does the candidate model’s parameter count appear as \(2k\) in the known-variance Cp formula?
  4. State the condition on a fuller model that makes \(RSS_F/(n-k_F)\) an unbiased estimate of the common error variance.
  5. How does expected squared error for future responses differ from the mean-response error targeted in the derivation, and why does the difference not change rankings on the same design?