Tutorials › Regression Analysis (Undergraduate) › Prediction Accuracy Versus Coefficient Recovery

Ridge and Lasso Regression · Tutorial 685 of 991

Prediction Accuracy Versus Coefficient Recovery

Learn why a model that predicts well need not recover the underlying regression coefficients, and how ridge and lasso can make that trade-off.

Advanced 11 min read

What You'll Learn

  • Distinguish prediction accuracy from coefficient recovery.
  • Express prediction error using the covariance of the predictors.
  • Explain how ridge shrinkage can trade coefficient bias for lower prediction error.
  • Assess why lasso may predict well while selecting a proxy among correlated predictors.
  • Separate performance on new observations from in-sample fit.
  • Recognize when a predictive model should not be interpreted as a scientific explanation.

Two Different Goals for a Regression Model

A regression model can be useful for forecasting an outcome without giving accurate estimates of the underlying effects of each predictor. This distinction matters in ridge and lasso regression because both methods deliberately constrain coefficient estimates: ridge shrinks them toward zero, while lasso can shrink some to exactly zero. Those changes can improve predictions, but they also mean that the fitted coefficients need not equal the coefficients that generated the data.

The key question is therefore not simply whether a model is “good.” It is: good for what purpose? If the purpose is to predict outcomes for new cases, performance should be assessed on new cases. If the purpose is to recover scientifically meaningful effects, coefficient accuracy and the scientific design matter. A small prediction error alone does not establish that the fitted coefficients recover those effects.

Definition: Prediction accuracy describes how close a model’s predictions are to outcomes for new observations from a specified population or setting. Coefficient recovery describes how close the estimated coefficients are to the model’s underlying coefficients. These are distinct goals: prediction error depends on how coefficient errors align with the predictors’ variation, whereas coefficient recovery concerns the coefficients themselves.

The Model and the Two Error Measures

For a fixed design matrix \(X\), consider the linear model \(y=X\beta+\varepsilon\). Here \(y\) is the vector of observed responses, \(X\) contains the predictor values, and \(\beta\) is the coefficient vector. Assume the errors have mean zero, are independent, and have common variance \(\sigma^2\). When discussing a new response at predictor vector \(x_0\), assume it follows the same linear mean model, \(Y_0=x_0^\mathsf{T}\beta+\varepsilon_0\), with an independent error of mean zero and variance \(\sigma^2\). The intercept, if included, is not penalized by ridge or lasso.

A coefficient-recovery measure is the squared Euclidean error \(\|\hat{\beta}-\beta\|^2\). Its size depends on the scale of the predictors, so coefficients should be compared using a stated, consistent scaling. For prediction, the error in the fitted conditional mean at \(x_0\) is \(x_0^\mathsf{T}(\hat{\beta}-\beta)\). The new response also contains the irreducible error \(\varepsilon_0\).

When new predictor vectors have mean zero and covariance matrix \(\Sigma\), the expected squared difference between the fitted conditional mean and the true conditional mean is

$$ E\left[\{X_0^\mathsf{T}(\hat{\beta}-\beta)\}^2\mid\hat{\beta}\right] =(\hat{\beta}-\beta)^\mathsf{T}\Sigma(\hat{\beta}-\beta). $$

This quantity weights coefficient errors according to how the predictors vary together. A large coefficient error in a direction where the predictors have little variation may have a small effect on predictions. Conversely, errors in a direction with substantial predictor variation can matter greatly. For a new response, the expected squared prediction error conditional on the fitted coefficients is this quantity plus \(\sigma^2\), provided the new error is independent of the predictors and fitted model.

Why Shrinkage Can Help Prediction

Ridge regression chooses coefficients by minimizing the residual sum of squares plus a penalty on squared coefficients. With tuning parameter \(\lambda>0\), the objective for penalized slopes is \(\|y-Xb\|^2+\lambda\|b\|^2\). Lasso instead adds a penalty on the sum of absolute coefficient values. In both cases, tuning controls the strength of the constraint. These definitions describe the criteria; selecting a tuning value for prediction requires evaluating candidate values using a suitable validation procedure, not judging the training fit alone.

A short calculation shows how ridge can reduce prediction error even though it introduces bias. For one predictor \(x\), the ridge estimate minimizes \(\|y-xb\|^2+\lambda b^2\). Differentiating with respect to \(b\) and setting the derivative to zero gives \(-2x^\mathsf{T}y+2x^\mathsf{T}xb+2\lambda b=0\). Thus

$$ \hat{\beta}_{\lambda}=\frac{x^\mathsf{T}y}{x^\mathsf{T}x+\lambda}. $$

Under the stated linear model, \(E(\hat{\beta}_{\lambda})=\frac{x^\mathsf{T}x}{x^\mathsf{T}x+\lambda}\beta\): the estimate is pulled toward zero, so it is biased when \(\beta\ne 0\). Its variance is \(\frac{\sigma^2 x^\mathsf{T}x}{(x^\mathsf{T}x+\lambda)^2}\), which is smaller than the OLS variance \(\frac{\sigma^2}{x^\mathsf{T}x}\) for \(\lambda>0\). Whether the reduction in variance outweighs the added squared bias depends on the signal, noise, design, and prediction target. Bias by itself does not determine prediction quality.

Worked Example: Ridge Shrinkage with a Noisy Predictor

Suppose a hypothetical one-predictor model has \(x^\mathsf{T}x=10\), true slope \(\beta=0.5\), and independent errors with variance \(\sigma^2=4\). Compare OLS with ridge using \(\lambda=10\). Assume new predictor values have mean zero and variance 1, and the new response has the same error variance.

For OLS, the estimate is unbiased and its variance, hence its coefficient mean squared error, is

$$ \operatorname{MSE}(\hat{\beta}_{\mathrm{OLS}}) =\frac{\sigma^2}{x^\mathsf{T}x} =\frac{4}{10} =0.4. $$

The ridge shrinkage factor is \(10/(10+10)=0.5\). Therefore its expectation is \(0.5(0.5)=0.25\), giving bias \(0.25-0.5=-0.25\). Its variance is

$$ \operatorname{Var}(\hat{\beta}_{\lambda}) =\frac{4(10)}{(10+10)^2} =\frac{40}{400} =0.1. $$

Ridge’s coefficient mean squared error is variance plus squared bias:

$$ \operatorname{MSE}(\hat{\beta}_{\lambda}) =0.1+(-0.25)^2 =0.1625. $$

In this hypothetical setup, ridge is biased but has lower coefficient mean squared error than OLS. Because the new predictor variance is 1, the expected squared error in the predicted conditional mean is \(0.1625\) for ridge and \(0.4\) for OLS. Including the new-response error variance gives expected response prediction errors of \(4.1625\) and \(4.4\), respectively. The ridge improvement is modest, and it depends on the stated assumptions and target distribution; it is not a guarantee that ridge will outperform OLS in every setting.

Correlated Predictors: Similar Predictions, Different Coefficients

With correlated predictors, substantially different coefficient vectors can produce similar predictions. If two predictors tend to move together, changes to their coefficients in opposite directions may have little effect on the fitted values. Consequently, a coefficient vector that is close to the truth in Euclidean distance is not the only route to accurate prediction; nor does accurate prediction ensure that each coefficient has been recovered.

Worked Example: Prediction Error Along a Low-Variation Direction

Suppose two standardized predictors for new cases have covariance matrix \(\Sigma=\begin{pmatrix}1&0.99\\0.99&1\end{pmatrix}\), and the true conditional mean is \(X_1+X_2\), so \(\beta=(1,1)^\mathsf{T}\). Compare two hypothetical fitted coefficient vectors, \(b_A=(0.8,0.8)^\mathsf{T}\) and \(b_B=(1.5,0.5)^\mathsf{T}\). The comparison concerns their conditional-mean prediction error under this predictor distribution.

For \(b_A\), the coefficient error is \(e_A=(-0.2,-0.2)^\mathsf{T}\). Its squared Euclidean coefficient error is \(0.2^2+0.2^2=0.08\). Its expected squared conditional-mean prediction error is

$$ e_A^\mathsf{T}\Sigma e_A =0.04(1+1+2(0.99)) =0.1592. $$

For \(b_B\), the coefficient error is \(e_B=(0.5,-0.5)^\mathsf{T}\). Its squared Euclidean coefficient error is \(0.5^2+(-0.5)^2=0.5\), much larger than \(0.08\). But its expected squared conditional-mean prediction error is

$$ e_B^\mathsf{T}\Sigma e_B =0.25(1+1-2(0.99)) =0.005. $$

Thus \(b_B\) is worse by the Euclidean coefficient-recovery measure but better for prediction under the stated predictor distribution. Its error adds to one coefficient and subtracts from the other, a direction in which the highly correlated predictors vary little. These are hypothetical fitted vectors, not a claim that a particular tuning procedure must produce either vector.

Lasso and the Limits of Variable Selection

Lasso can set some fitted coefficients to zero, which is useful when a sparse predictive model is desired. But a selected predictor is not automatically a uniquely identified scientific cause or effect, and a zero coefficient does not prove that the predictor has no relationship with the outcome. When predictors are correlated, different choices among them can represent much the same predictive information. The lasso selection behavior covered in the earlier material on lasso selection among correlated predictors is therefore relevant to interpretation as well as to fitting.

Worked Example: A Selected Proxy Can Predict Well

Consider the same hypothetical predictor distribution with correlation \(0.99\), and true coefficient vector \(\beta=(1,1)^\mathsf{T}\). Assume the new response has independent error variance \(\sigma^2=1\). Suppose a lasso fit yields \(b=(2,0)^\mathsf{T}\): it selects the first predictor and sets the second coefficient to zero.

The coefficient error is \(b-\beta=(1,-1)^\mathsf{T}\), so the squared Euclidean coefficient error is \(1^2+(-1)^2=2\). The conditional-mean prediction error is instead

$$ \begin{aligned} (b-\beta)^\mathsf{T}\Sigma(b-\beta) &=1+1-2(0.99)\\ &=0.02. \end{aligned} $$

The expected squared prediction error for a new response is \(1+0.02=1.02\): \(1\) from the new error and \(0.02\) from the fitted conditional mean. Under this distribution, the fitted model predicts nearly as well as the true conditional mean, although its coefficients do not recover the two true effects. The zero for the second predictor should not be read as evidence that its scientific effect is absent. It describes this penalized fit, in this correlated-predictor setting.

Evaluate the Goal You Actually Have

A model’s training residuals measure fit to the data used to estimate it; they do not by themselves measure accuracy for new cases. For a prediction goal, assess performance on data not used to fit or tune the model, using a loss aligned with the intended outcome and prediction task. The earlier material on cross-validation for penalized regression and leakage-free tuning of penalized models provides relevant procedures. A validation score estimates predictive performance for a target setting; it does not measure whether the fitted coefficients equal the scientific effects.

For coefficient recovery, first define what the scientific coefficients mean and how predictors are scaled. Then consider whether the data and design can distinguish their contributions. Correlation can make the prediction-relevant combination of coefficients better determined than the individual coefficients. Penalization can stabilize predictions by favoring particular coefficient patterns, but that stability does not, on its own, establish that the favored pattern is scientifically correct. Ordinary OLS inference also cannot simply be transferred to penalized estimates, as discussed in the earlier material on why penalized estimates lack ordinary OLS inference.

Common Mistake: Treating Prediction as Proof of Effects

  • Wrong reasoning: “The lasso model predicts accurately and assigns a zero to this predictor, so the predictor has no effect.”
  • Correction: Predictive accuracy assesses how well the model forecasts outcomes under a particular predictor distribution and loss. A zero penalized coefficient, especially with correlated predictors, does not establish that the underlying scientific effect is zero.
  • Wrong reasoning: “Ridge coefficients are biased, so ridge must predict poorly.”
  • Correction: Bias is one component of estimation error. Shrinkage can reduce variance enough to improve prediction, as the worked example illustrates. Performance must be evaluated for the intended prediction target.

The distinction is practical, not merely technical. If the goal is prediction, choose and assess a model for its performance on appropriate new cases. If the goal is scientific explanation or effect estimation, predictive performance is not a substitute for a design and analysis that support that interpretation. A model can be useful for one goal and inadequate for the other.

Key takeaway: Coefficient errors affect predictions through the variation and dependence structure of the predictors. Ridge and lasso may therefore predict well while their coefficients are biased, unstable, or poor representations of scientifically meaningful effects. State which goal matters, and use evidence suited to that goal.

Check Your Understanding

Answer each question using the distinction between predictive performance and coefficient recovery.

  1. In your own words, what does coefficient recovery measure, and how is it different from prediction accuracy?
  2. Why can an error in a low-variation direction of correlated predictors have little effect on predictions?
  3. In the ridge example, identify the source of the bias and the reason the ridge estimate nevertheless had lower mean squared error than OLS.
  4. A lasso model predicts well but sets one of two highly correlated predictors to zero. What conclusion about that predictor’s scientific effect is justified by this fact alone?
  5. Why should predictive performance be evaluated using data not used to fit or tune the model?