Tutorials › Regression Analysis (Undergraduate) › Assessing Lasso Selection Stability

Ridge and Lasso Regression · Tutorial 687 of 991

Assessing Lasso Selection Stability

Use repeated resampling to measure how reproducibly lasso selects each predictor and to recognize when correlated variables exchange places.

Advanced 11 min read

What You'll Learn

  • Define a lasso selection frequency from repeated model fits
  • Set up bootstrap samples or repeated training splits for a stability check
  • Keep preprocessing and the tuning rule consistent across resamples
  • Calculate selection frequencies and their Monte Carlo variability
  • Diagnose fragile individual predictors and stable correlated groups
  • Explain why selection frequency is not a probability that a predictor is truly important

Why Check Selection Stability?

A lasso fit gives a particular set of selected predictors for a particular data set and tuning choice. But when predictors carry overlapping information, small changes in the observations can change which variables receive nonzero coefficients. A selected variable may therefore be part of a reproducible pattern, or it may be one of several plausible substitutes that happened to win in this fit.

Selection stability asks a practical question: if we repeated the analysis on slightly different versions of these data, how often would each predictor be selected? The answer helps describe how sensitive the fitted selection is. It does not establish that a predictor causes the response, nor does it supply ordinary confidence intervals or a probability that a predictor is truly relevant.

Definition and Setup

For each resampled data set, fit a lasso model and record whether each predictor is selected. In this tutorial, a predictor is selected when its fitted lasso coefficient is nonzero, using a consistent numerical tolerance if the software reports tiny values as zero. The intercept is not counted as a selected predictor.

Definition: For predictor \(j\), the selection frequency is the fraction of resampled fits in which its lasso coefficient is nonzero. If \(I_{bj}=1\) when predictor \(j\) is selected in resample \(b\), and \(I_{bj}=0\) otherwise, then $$ \hat{\pi}_j=\frac{1}{B}\sum_{b=1}^{B} I_{bj}, $$ where \(B\) is the number of resampled fits. A frequency of 0.80 means that the predictor was selected in 80% of those fits.

A lasso fit depends on choices such as predictor coding, scaling, the penalty parameter, and the rule for choosing that parameter. A stability analysis is meaningful only when these choices are handled consistently. A typical setup centers the response and standardizes quantitative predictors within each training sample, leaves the intercept unpenalized, and applies the same selection rule in every fit. If categorical predictors are represented by several indicator columns, decide in advance whether selection is recorded per column or for the factor as a whole.

There are two useful ways to handle the penalty. One is to hold a chosen penalty value fixed across resamples; this checks stability conditional on that value. Another is to repeat the tuning procedure inside each resample; this checks stability of the full modeling procedure, including tuning. These are different questions, so report which one was used. When tuning is repeated, use only the resample’s training data to tune its model; do not use held-out observations in the tuning step.

Choosing Resamples

In the ordinary bootstrap, each resample consists of \(n\) rows drawn with replacement from the original \(n\) observations. Some observations occur more than once and some are omitted. Refit the lasso to each bootstrap sample and record the selections. For independent observations sampled in a similar way, this is a common way to examine sensitivity to the particular cases in the data.

Alternatively, repeatedly fit the model on randomly chosen subsets or training portions of the data. The number of rows in each training portion should be stated, since smaller training sets can produce more variable selections. If the observations are clustered, paired, or ordered in time, ordinary row-by-row resampling may break their structure; the resampling scheme should preserve the relevant units or ordering.

Neither scheme creates new independent scientific studies. The resulting frequencies describe the behavior of the specified fitting procedure under the chosen resampling scheme, conditional on the observed data. They are descriptive diagnostics, not a replacement for subject-matter reasoning or an inferential guarantee.

Worked Example: Calculating Bootstrap Selection Frequencies

Suppose a hypothetical analysis has \(n=120\) observations and six standardized predictors. The analyst draws \(B=100\) bootstrap samples, each containing 120 rows drawn with replacement, and refits the lasso at the same prespecified penalty in every sample. The numbers of fits selecting four predictors are as follows.

PredictorFits selectedSelection frequency
Age860.86
Baseline score720.72
Exposure duration390.39
Site indicator110.11

For baseline score, the calculation is $$ \hat{\pi}_{\text{baseline}}=\frac{72}{100}=0.72. $$ Thus baseline score was selected in 72 of these 100 bootstrap fits. Age was selected more frequently, while the site indicator was selected much less frequently. These results describe the resampled fits; by themselves, they do not prove that age is important or that the site indicator is irrelevant.

Because the 100 resamples are a finite Monte Carlo run, the reported frequency also varies somewhat from run to run. For a selection frequency near 0.72, the approximate Monte Carlo standard error is $$ \sqrt{\frac{0.72(1-0.72)}{100}} =\sqrt{0.002016} \approx 0.0449. $$ This measures simulation variability in estimating the resampling procedure’s selection rate, not uncertainty about whether baseline score belongs in a true model.

What the Frequency Measures

The frequency has a simple justification. For a fixed observed data set and a fixed resampling and fitting procedure, each resample produces an indicator \(I_{bj}\) equal to 1 if predictor \(j\) is selected and 0 otherwise. If resamples are independently generated from that procedure, these indicators have a common selection rate \(\pi_j\). Their average is the observed frequency, and the average of \(B\) independent zero-one indicators has variance \(\pi_j(1-\pi_j)/B\). Replacing the unknown \(\pi_j\) by its observed estimate gives the Monte Carlo standard error formula used above: $$ \widehat{SE}_{MC}(\hat{\pi}_j) =\sqrt{\frac{\hat{\pi}_j(1-\hat{\pi}_j)}{B}}. $$

This calculation explains why more resamples reduce Monte Carlo noise: the standard error decreases at a rate proportional to \(1/\sqrt{B}\). It does not account for the fact that the original data set is itself only one sample from a broader population. In particular, it must not be interpreted as an ordinary standard error for a regression coefficient or as a confidence interval for a scientific effect.

Worked Example: Correlated Predictors Can Trade Places

Consider two hypothetical, strongly correlated measurements, \(X_1\) and \(X_2\), that provide similar information about an outcome. Across 200 bootstrap lasso fits at a fixed penalty, \(X_1\) is selected 116 times and \(X_2\) is selected 84 times. In this example, exactly one of the two is selected in every fit.

Their individual frequencies are $$ \hat{\pi}_1=\frac{116}{200}=0.58, \qquad \hat{\pi}_2=\frac{84}{200}=0.42. $$ Neither variable is selected nearly every time. Yet the frequency that at least one member of the pair is selected is $$ \frac{116+84}{200}=\frac{200}{200}=1.00, $$ because exactly one is selected in each fit.

The appropriate diagnosis is that selection of the individual variable is sensitive, while the choice of one variable from the pair is completely stable in these resamples. This pattern is consistent with the lasso’s tendency to choose among correlated predictors. It does not show that the two predictors have identical effects or that either is unimportant. If the scientific question concerns their shared information, report the group pattern as well as the individual frequencies, making clear how the group was defined.

Separating Penalty Stability from Procedure Stability

A fixed penalty isolates one source of variation: which predictors are selected when the penalty is held constant and the rows change. But a full modeling workflow often chooses the penalty from the data, for example by cross-validation. To study that workflow, the tuning step should be repeated within each resample, using the same tuning rule and loss. This allows the selected penalty, as well as the observations, to vary across fits.

Worked Example: Fixed Penalty Versus Retuning

In a hypothetical data set, an analyst generates 50 bootstrap samples. For each sample, the analyst fits the lasso twice: once using a fixed penalty and once after choosing the penalty by the same cross-validation rule within that bootstrap sample. Predictor \(Z\) is selected in 41 fixed-penalty fits and 29 retuned fits.

The fixed-penalty frequency is $$ \frac{41}{50}=0.82, $$ and the retuned frequency is $$ \frac{29}{50}=0.58. $$ The difference is \(0.82-0.58=0.24\), or 24 percentage points. In this example, selection of \(Z\) is more common when the penalty is held fixed than under the full retuning procedure.

The difference is a diagnostic, not evidence that one calculation is wrong. It says that the conclusion depends partly on whether the penalty is fixed or retuned. A report should state the two procedures separately rather than present 0.82 and 0.58 as interchangeable estimates of one quantity.

Reading Frequencies Carefully

A high frequency indicates that a predictor is repeatedly selected by this particular procedure under this particular resampling scheme. A low or intermediate frequency signals sensitivity: modest changes to the sampled rows, and possibly to the tuning result, often change the selected set. There is no universal cutoff at which a predictor becomes “stable.” A threshold such as 0.80 may be useful as a prespecified descriptive rule in a particular analysis, but it is not a general statistical boundary.

Common mistake: “Predictor A was selected in 90% of bootstrap fits, so there is a 90% probability that A is truly important.” This is incorrect: 0.90 is the observed selection rate under the chosen resampling and fitting procedure, conditional on the data and analysis choices. It is not a probability about the scientific truth of a predictor’s role. A correct statement is: “Predictor A was selected in 90% of the bootstrap fits produced by this specified procedure.”

Stability analysis matters because a single sparse lasso fit can give a deceptively definite-looking list of variables. Resampling reveals whether that list recurs or whether small data changes rearrange it. A stable prediction procedure can still have unstable individual selections, especially with correlated predictors; conversely, a frequently selected variable is not automatically scientifically meaningful. Treat selection frequencies as a transparent description of sensitivity, alongside the modeling goal and the substantive context.

Check Your Understanding

Use these questions to check your interpretation of lasso selection stability.

  1. Across 80 resampled fits, a predictor is selected 52 times. What is its selection frequency, and what does that value describe?
  2. Why should a cross-validation tuning step be repeated within each resample when the goal is to assess stability of the full modeling procedure?
  3. Two correlated predictors have individual frequencies of 0.46 and 0.49, but at least one is selected in 0.95 of fits. What pattern does this suggest?
  4. What does the Monte Carlo standard error of a selection frequency quantify, and what does it not quantify?
  5. Why might ordinary row-by-row bootstrap sampling be inappropriate for clustered observations?
Back to Tutorials