Tutorials › High-Dimensional Genomic Data Analysis › Post-Lasso Refitting and the Cost of Removing Shrinkage

Penalized Regression for p Much Larger Than n · Tutorial 540 of 795

Post-Lasso Refitting and the Cost of Removing Shrinkage

Learn how post-lasso refitting changes fitted values, coefficient variability, and out-of-sample prediction, including the rank conditions needed for a unique least-squares fit.

Advanced 10 min read

What You'll Learn

  • Define the post-lasso refit and distinguish it from the original lasso fit.
  • Compare their training residual sums of squares and explain why the refit can overfit.
  • State the exact rank conditions for unique coefficients and positive residual degrees of freedom.
  • Derive prediction variance for a fixed selected model and identify the role of selection.
  • Use held-out prediction error and design diagnostics to assess whether refitting helps.
  • Distinguish post-lasso refitting from ridge, elastic net, and choosing a new penalty.

Why Refit After Lasso?

The lasso can serve two purposes: it predicts a response and it selects predictors by setting some estimated coefficients exactly to zero. Its penalty also shrinks the coefficients that remain. A post-lasso refit keeps the selected predictors but estimates their coefficients again by ordinary least squares, without the lasso penalty. This can reduce shrinkage bias when the selected set is appropriate, but it removes a source of regularization. In a high-dimensional genomic setting, the resulting fit can be more sensitive to noise and less accurate on new samples.

The comparison concerns two different fitted models, not merely two ways to report the same coefficients. The lasso chooses a sparse, penalized fit using the full predictor set; the refit then treats that selected set as the model to estimate. Whether the second step improves prediction is an empirical question, not a guaranteed consequence of reducing coefficient shrinkage.

Definition: For a response vector \(y\in\mathbb{R}^n\) and predictor matrix \(X\in\mathbb{R}^{n\times p}\), consider the lasso objective $$ \frac{1}{2n}\|y-X\beta\|_2^2+\lambda\|\beta\|_1,\qquad \lambda\geq 0. $$ Assume the response and predictor columns have been centered, or that an intercept is included and left unpenalized. Let \(S=\{j:\hat{\beta}^{\,L}_j\neq 0\}\) be the predictors selected by a lasso fit \(\hat{\beta}^{\,L}\). A post-lasso least-squares refit estimates coefficients using only the columns \(X_S\), by minimizing \(\|y-X_S b\|_2^2\) over \(b\in\mathbb{R}^{|S|}\). Its predictions are \(X_S\hat b^{\,OLS}\).

The selected set depends on the data and on the chosen penalty \(\lambda\). For a clean comparison, first suppose that \(S\) has already been chosen. The refit minimizes training residual sum of squares among all coefficient vectors using those predictors. Since the lasso coefficients restricted to \(S\) are one such vector, the refit cannot have a larger training residual sum of squares. That fact alone says nothing about prediction on new observations.

What Least Squares Requires

The refit has a unique coefficient vector exactly when \(X_S\) has full column rank. In that case, $$ \hat b^{\,OLS}=(X_S^\mathsf{T}X_S)^{-1}X_S^\mathsf{T}y. $$ Full column rank implies \(|S|\leq n\), but it does not require \(|S|<n\). If \(|S|=n\) and \(X_S\) is invertible, the coefficient solution is unique, although the fit has zero residual degrees of freedom. Positive residual degrees of freedom require \(n-\operatorname{rank}(X_S)>0\). If columns are linearly dependent, the minimizing fitted values are unique, but the coefficient vector need not be unique; software may return one solution under an additional convention or use a generalized inverse.

These conditions matter especially when \(p\) is much larger than \(n\). A lasso fit can select more than \(n\) predictors in some settings, and selected columns can also be nearly or exactly collinear. In either case, the ordinary inverse formula is unavailable. Even when the selected design has full rank, near-collinearity makes the inverse Gram matrix unstable: small changes in the data can produce large changes in the refitted coefficients.

Worked Example: Training Fit and the Cost of Removing Shrinkage

Consider a hypothetical centered data set with \(n=4\), one selected predictor \(x\), \(x^\mathsf{T}x=4\), and response \(y=2x+e\), where \(x^\mathsf{T}e=0\) and \(e^\mathsf{T}e=4\). Fit the one-predictor lasso with \(\lambda=0.5\) under the objective above, then compare it with a least-squares refit.

The lasso coefficient minimizes the objective as a function of \(b\). Since \(x^\mathsf{T}x/n=1\) and \(x^\mathsf{T}y/n=2\), the positive-coefficient solution satisfies \(b=x^\mathsf{T}y/n-\lambda=1.5\). The post-lasso refit is the unpenalized least-squares estimate: $$ \hat b^{\,OLS}=\frac{x^\mathsf{T}y}{x^\mathsf{T}x} =\frac{2(4)}{4}=2. $$

The lasso residual is \(y-1.5x=e+0.5x\). Orthogonality gives its sum of squares as \(e^\mathsf{T}e+0.25x^\mathsf{T}x=4+1=5\). The refit residual is \(e\), with sum of squares \(4\). Thus refitting lowers training residual sum of squares by \(1\), as it must. The calculation does not establish that the refit predicts better: if the selected signal is weak or partly due to noise, the extra coefficient movement can worsen new-sample prediction.

Why Variance Can Increase

A standard calculation makes the variance cost visible. Suppose the selected set \(S\) is fixed independently of the response, the linear model \(y=X_S\beta_S+\varepsilon\) is correct, \(X_S\) has full column rank, and the errors have mean zero and covariance \(\sigma^2 I\). Then $$ \hat b^{\,OLS}=\beta_S+(X_S^\mathsf{T}X_S)^{-1}X_S^\mathsf{T}\varepsilon, \qquad \operatorname{Cov}(\hat b^{\,OLS})=\sigma^2(X_S^\mathsf{T}X_S)^{-1}. $$ For a new predictor vector \(x_0\), the variance of the estimated conditional mean \(x_0^\mathsf{T}\hat b^{\,OLS}\) is therefore $$ \operatorname{Var}(x_0^\mathsf{T}\hat b^{\,OLS}) =\sigma^2x_0^\mathsf{T}(X_S^\mathsf{T}X_S)^{-1}x_0. $$ The expression grows when the model includes directions that are poorly estimated, such as nearly collinear predictors, or when more noisy predictors contribute to the prediction. Predicting a future response adds its irreducible error variance \(\sigma^2\) to the mean-prediction error under these assumptions.

Justification: Under the fixed-set model, subtract \(\beta_S\) from the least-squares formula to obtain \(\hat b^{\,OLS}-\beta_S=(X_S^\mathsf{T}X_S)^{-1}X_S^\mathsf{T}\varepsilon\). Taking its covariance and using \(\operatorname{Cov}(\varepsilon)=\sigma^2I\) yields $$ (X_S^\mathsf{T}X_S)^{-1}X_S^\mathsf{T}(\sigma^2I)X_S(X_S^\mathsf{T}X_S)^{-1} =\sigma^2(X_S^\mathsf{T}X_S)^{-1}. $$

The assumptions in this calculation are important. In actual post-lasso fitting, \(S\) was selected using \(y\), so it is not fixed independently of the errors. The displayed covariance is a useful description of the variability of a fixed-model refit, but it does not by itself give the full sampling distribution after selection. Selection can add variability, and estimates conditional on having been selected need not behave like estimates from a model specified in advance.

There is another useful nuance: on a region of the data where a lasso fit has the same active set and coefficient signs, its active coefficients can be written as least squares minus a penalty-dependent offset. With the objective used here, for fixed active set and signs \(s\), this expression is $$ \hat\beta^{\,L}_S=\hat b^{\,OLS}-n\lambda(X_S^\mathsf{T}X_S)^{-1}s. $$ The offset is constant within that region, so the local covariance there is not automatically smaller than the least-squares covariance. The benefit of shrinkage is not a universal variance reduction under every conditioning scheme. Rather, regularization constrains the fit across data sets and can reduce overall prediction error by trading some bias for less sensitivity. Removing that constraint can increase variance in practice, but does not have to do so in every data set.

Worked Example: More Selected Directions, More Prediction Variance

Suppose a hypothetical fixed design has \(n=40\) observations, error variance \(\sigma^2=1\), and mutually orthogonal selected columns, each with squared length \(40\). Assume the fixed-set model conditions above hold. At a new point, let each selected predictor value equal \(1\). Compare the mean-prediction variance for a refit using \(k=2\) columns with one using \(k=8\).

For orthogonal columns, \(X_S^\mathsf{T}X_S=40I_k\), so its inverse is \(I_k/40\). With \(x_0\) a vector of \(k\) ones, $$ \operatorname{Var}(x_0^\mathsf{T}\hat b^{\,OLS}) =1\cdot x_0^\mathsf{T}\frac{I_k}{40}x_0 =\frac{k}{40}. $$ For \(k=2\), the variance is \(2/40=0.05\). For \(k=8\), it is \(8/40=0.20\). In this design and at this prediction point, the larger refit has four times the mean-prediction variance. This illustrates the variance cost of estimating additional directions; it does not prove that any particular post-lasso fit will be worse, because signal bias and the selection process also affect predictive error.

Assessing the Trade-Off

A post-lasso refit can help when the selected set contains the important predictors, the lasso has materially shrunk their coefficients, and the selected design is well-conditioned. It can hurt when the selected set includes noise variables, when many predictors are weakly supported, or when collinearity makes the refitted coefficients unstable. The relevant target is prediction on new data, so compare lasso and post-lasso predictions using the same held-out observations or a properly designed validation procedure. Do not choose the refit because it has lower training error: that decrease is built into the optimization.

Useful diagnostics include the number of selected columns relative to \(n\), the rank and condition of \(X_S\), the size and variability of refitted coefficients, and validation error across data splits. Large coefficient changes after refitting, unstable signs, or a rise in held-out error are warnings that the removed shrinkage was serving a useful role. A selected model with \(|S|=n\) and full rank can interpolate the training response, but has no residual degrees of freedom; a larger selected set cannot have full column rank. Near rank deficiency may be problematic even before exact non-uniqueness occurs.

The main alternatives answer different questions. The original lasso retains shrinkage and selection in one fit. Ridge regression shrinks coefficients without setting them exactly to zero, while elastic net combines an \(L_1\) and an \(L_2\) penalty and can retain groups of correlated predictors. A post-lasso refit removes shrinkage only after selection; it does not reselect predictors or automatically correct for selection-induced uncertainty. Comparing these approaches on out-of-sample predictions is more informative than comparing their training residual sums of squares.

ApproachWhat it does after or during fittingMain caution
LassoSelects predictors and shrinks estimated coefficients.May shrink important effects and may select inconsistently among correlated predictors.
Post-lasso least squaresKeeps the lasso-selected set and removes coefficient shrinkage.Can increase variance; requires attention to rank and validation performance.
Ridge or elastic netRetains penalty-based shrinkage; elastic net can combine sparsity with group-like behavior.Does not make post-selection refitting equivalent to the penalized fit.

Common Mistake

Wrong reasoning: “The post-lasso model has lower training error, so it must predict better.” Least squares is optimized to lower residual sum of squares on the selected training data; this is not evidence that its predictions generalize. Correction: assess prediction on data not used to fit or select the model, and account for the instability that can arise from both selection and refitting. A second mistake is to require \(|S|<n\) for unique least-squares coefficients. Full column rank is the condition for a unique coefficient solution and implies \(|S|\leq n\); strictly fewer independent columns than observations is needed for positive residual degrees of freedom.

Key takeaway: Post-lasso refitting trades the lasso’s coefficient shrinkage for an unpenalized fit on the selected predictors. It lowers training residual sum of squares, but may increase prediction variance and overfit. Rank conditions establish whether the refit is uniquely defined; held-out prediction and design diagnostics help determine whether removing shrinkage is worthwhile.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. Why can a post-lasso refit not have a larger training residual sum of squares than the lasso fit on the same selected set?
  2. A selected design has \(n=12\) rows and 12 linearly independent columns. Is its least-squares coefficient solution unique? Does it have positive residual degrees of freedom?
  3. In the fixed-set model, \(X_S^\mathsf{T}X_S=25I_3\), \(\sigma^2=2\), and \(x_0=(1,1,1)^\mathsf{T}\). Calculate the variance of the estimated conditional mean at \(x_0\).
  4. Give one reason why the fixed-set covariance formula may not fully describe actual post-lasso variability.

Solutions. (1) The lasso coefficients restricted to the selected predictors are feasible candidates for the least-squares minimization, and least squares minimizes residual sum of squares over that set; therefore its minimum cannot be larger. (2) Yes. Full column rank gives a unique coefficient solution, including when the design is square. Its residual degrees of freedom are \(12-12=0\), so they are not positive. (3) The variance is \(\sigma^2 x_0^\mathsf{T}(X_S^\mathsf{T}X_S)^{-1}x_0=2(3/25)=0.24\). (4) The selected set was chosen using the response, so it is data-dependent rather than fixed independently of the errors; selection can contribute variability not captured by the fixed-set formula.

Clinical Biostats