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.
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.
| Predictor | Fits selected | Selection frequency |
|---|---|---|
| Age | 86 | 0.86 |
| Baseline score | 72 | 0.72 |
| Exposure duration | 39 | 0.39 |
| Site indicator | 11 | 0.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}}. $$