Math calculator

Lasso Regression Calculator

Which ones survive.

Which ones survive

Eighty observations, six correlated predictors, and a noisy outcome. Only x1 and x2 have any real effect — the true coefficients of x3 through x6 are exactly zero. Lasso selects x1, x2 and x4, which is two right and one wrong. Resample the same rows sixty times and refit at the same penalty: sixteen distinct predictor sets come back, and this one reappears in only 33.3% of them. The noise variable x4 survives 75.0% of the time and x3 survives 18.3%, and nothing separates them but chance. The prediction error, meanwhile, varies by just 19.9%.

80 rows · 6 predictors · penalty 0.2 · cross-validated error 7.1547

3 of 6 predictors survive — and resampling returns 16 different sets

The set found on the full data reappears in only 33.3% of 60 resamples, while the prediction error across those same resamples varies by 19.9%. The fit is stable; the story told about which predictors matter is not. Read the stability column before quoting the selected set as a finding.

Predictors selected

3 of 6

at penalty 0.2

Distinct sets on resampling

16

across 60 resamples

This set reappears

33.3%

of the time

Prediction error varies

19.9%

far less than the set does

Every predictor, and how often it survives

Coefficient, selection status and resampling stability for each predictor
PredictorLeast squaresLassoIn the setSurvives in
x11.86151.5091selected100.0%
x21.08400.4717selected90.0%
x3-0.63830dropped18.3%
x40.81570.4518selected75.0%
x5-0.00060dropped21.7%
x6-0.54010dropped25.0%

The last column is the share of 60 bootstrap resamples in which that predictor survived at this penalty. A predictor selected on the full data but surviving in half the resamples is a coin toss dressed as a conclusion, and a predictor at 100% is genuinely carrying signal. That column is the honest version of the selected set.

The penalty path

Cross-validated error and surviving predictor count at each penalty
PenaltyPredictors keptCross-validated errorIts standard error
0.000557.347381.20525
0.00157.346201.20470
0.00557.337441.20030
0.0157.328501.19490
0.02557.316811.17762
0.0557.317821.14928
0.147.265911.09279
0.237.154691.04074lowest error
0.437.301311.05439one standard error rule
None (least squares)67.348562.64% worse

The count of surviving predictors falls monotonically as the penalty rises, which it must, and the error falls then climbs. The one-standard-error rule picks the largest penalty still within one standard error of the best — here 0.4, keeping 3 predictors — on the argument that a shorter list should win a statistical tie.

Exact zeros come from the shape of the penalty, not from a threshold applied afterwards. The absolute-value penalty has a corner at the origin that a coefficient can settle into; the squared penalty ridge uses is smooth there and never produces one.

Among correlated predictors lasso keeps one and drops the rest, and which one it keeps is close to arbitrary. Elastic net softens that by mixing in a ridge penalty, at the cost of a longer list. Neither turns the selected set into a hypothesis test.

Exact zeros Stability per predictor Least squares beside it Full penalty path Selection resampled

What this tool shows

Resampling the same eighty rows sixty times returns sixteen different predictor sets, and the one found on the full data reappears in 33.3% of them. The prediction error across those same resamples varies by 19.9%. The fit is stable; the short list of “important predictors” is not. And the list is wrong: x3 through x6 were generated with true coefficients of exactly zero, and lasso selected x4 — surviving 75.0% of resamples — while dropping x3 at 18.3%. Nothing separates those two but the sample.

  • A lasso path with cross-validated error and the number of predictors kept at each penalty
  • How often every predictor survives when the rows are resampled, on every run
  • How many distinct predictor sets appear, and how often the reported one recurs
  • Prediction error variability for contrast, which is far smaller
  • The one-standard-error rule alongside the minimum-error choice
  • Least squares beside the path, so the cost of selecting is visible
Exact zeros Stability per predictor Least squares beside it Full penalty path

A selected set is a choice the sample made, not a finding.

Updated 13 September 2026 · Works in any browser, no installation

Lasso adds a penalty on the absolute size of the coefficients, which drives some of them to exactly zero and leaves a shorter list of predictors. That automatic selection is why it is reached for, and it is the part to distrust: the coefficients and the predictions are reasonably stable, while the identity of the selected predictors moves substantially from one sample to the next. Lasso is a good prediction tool and a poor inference tool, and the difference is measurable rather than philosophical.

At a glance

Formula shown
Lasso minimises ‖y − Xβ‖²/2n + λ‖β‖₁ on standardised predictors, fitted here by coordinate descent with soft thresholding. The absolute-value penalty has a corner at the origin, which is what allows a coefficient to settle at exactly zero — a squared penalty is smooth there and never does. As λ rises the number of surviving predictors falls monotonically, and the penalty is chosen by cross-validation.
Scenario support
Screening many candidate predictors down to a workable few, building a prediction model where a shorter formula is easier to deploy, exploratory work on wide datasets, and any setting where interpretability matters more than using every available variable.
Educational estimate
Planning support from the values you enter — not professional advice.

The list that moves

The preset was generated so the answer is known: x1 and x2 have true coefficients of 1.2, and x3 through x6 have true coefficients of exactly zero. Eighty observations, six correlated predictors, a noisy outcome.

Lasso selects x1, x2 and x4. Two correct and one wrong — x4 is pure noise. That alone is not damning; any selection method makes mistakes on noisy data.

What is damning is what happens on resampling. Draw eighty rows with replacement from the same eighty, refit at the same penalty, and repeat sixty times. Sixteen distinct predictor sets come back. The set found on the full data appears in 33.3% of them. Two thirds of the time, the same data-generating process and the same procedure produce a different answer to “which predictors matter”.

The per-predictor stability column shows where the instability lives. x1 survives 100% of the time and x2 90% — those are the real ones, and the procedure finds them reliably. Among the four noise variables, x4 survives 75.0%, x6 25.0%, x5 21.7% and x3 18.3%. All four have identical true coefficients of zero. The gap between 75% and 18% is entirely the sample.

Meanwhile the prediction error across those sixty resamples varies by 19.9%. The model predicts about as well whichever set it lands on, because the correlated predictors substitute for one another. That is the whole picture: stable predictions, unstable explanations, and reporting only the selected set presents the unstable half as the result.

Why correlated predictors make it worse

When two predictors carry much the same information, lasso keeps one and zeroes the other. It has to: including both costs penalty for little extra fit, so the cheaper solution uses one. Which one it keeps is decided by a small difference in sample correlation that can flip with a handful of rows.

This is not a flaw in the implementation. It follows from the geometry, and it means the selected set should be read as “a sufficient set” rather than “the important variables”. A predictor dropped by lasso may be just as related to the outcome as the one kept; it was simply redundant given the other.

Which is why reporting a lasso selection as a finding about the world is a category error. The statement lasso supports is “these predictors suffice to predict about this well”. The statement usually made is “these are the predictors that matter”, and the resampling table is the cheapest available evidence about how far apart those two are.

Why there are no p-values here

A lasso fit has no standard errors and no p-values, and the omission is deliberate rather than an unfinished feature.

The difficulty is that the selection used the same data as the fit. Once a predictor has been chosen because it looked strong in this sample, its coefficient in this sample is conditioned on that choice, and the usual distribution theory does not apply. Computing an ordinary standard error on the surviving coefficients — which is easy, and common — produces intervals that are far too narrow, because they ignore that the model was picked by looking.

Post-selection inference is an active field with real methods, and none of them is a one-line addition to a lasso fit. What this page offers instead is the resampling column: an honest, direct statement of how reproducible each selection is, which is often what a reader actually wants from a p-value here.

The related trap is refitting least squares on the selected predictors and reporting those standard errors. That looks rigorous and is worse than reporting nothing, because it attaches a confident interval to a set of variables chosen for looking good in the same data.

Choosing the penalty, and what it changes

The path shows the number of surviving predictors falling monotonically as the penalty rises, from everything at a small penalty to nothing at a large one. The cross-validated error falls, reaches a minimum, then climbs.

The one-standard-error rule picks the largest penalty whose error is still within one standard error of the best, which here keeps a shorter list at effectively the same accuracy. For a method whose output is a list, that rule matters more than it does for ridge: it is the difference between reporting five predictors and three, on data that cannot distinguish the two.

The penalty is itself a cross-validated quantity and inherits that procedure’s variability, which the cross-validation page measures directly. A penalty that moves across a tenfold range when the folds are re-drawn will move the selected set with it, so some of the instability in the table above comes from the tuning rather than from the fit.

When to reach for something else

If the goal is prediction and the predictors are correlated, ridge is usually the better choice. It keeps everything, shrinks everything, and does not pretend to answer a question about which variables matter.

If a shorter list is genuinely wanted but the instability above is unacceptable, elastic net mixes the two penalties and keeps correlated predictors together rather than picking one. The measured trade is a longer list with higher per-predictor stability, at essentially unchanged error.

If the problem is collinearity rather than too many predictors, component regression replaces the predictors with a few directions instead of selecting among them — a different trade with a failure mode of its own.

Reporting it

Report the selection stability, not just the selection. A table of predictors with the share of resamples each survived is more informative than a list, takes one extra column, and prevents the error the preset demonstrates: presenting a set that reproduces a third of the time as a finding.

Say how the penalty was chosen and whether the minimum or the one-standard-error rule was used. The two frequently give different lists.

Do not attach p-values or confidence intervals to lasso coefficients, and do not refit least squares on the selected variables and report those. If inference is the goal, the model should be specified before looking at the data, or a post-selection method should be used and named.

Sources and methodology

References for the estimator, its computation and its selection behaviour.

Method. Coefficients are fitted by cyclic coordinate descent with soft thresholding on standardised predictors, and the penalty is scaled by n so that a given value means the same thing as on the ridge page. The suite confirms that at a vanishing penalty the fit approaches least squares and keeps every predictor, that the surviving count falls monotonically along the path, and that with no lasso share the same routine reproduces the closed-form ridge fit to within 1e-8 — a coordinate-descent method agreeing with a matrix inverse. Selection stability comes from sixty deterministic bootstrap resamples refitted at the chosen penalty, with out-of-bag error recorded for the prediction-variability contrast. That engine is verified on every change against 395 assertions. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

Ridge RegressionFit ridge regression across a penalty path chosen by cross-validation, with least squares beside it and the shrinkage applied to every coefficient shown.
Elastic NetFit an elastic net across the mixing dial from pure lasso to pure ridge, with selection stability and cross-validated error computed at each end.
Cross-ValidationRun k-fold cross-validation over a penalty path and repeat it across twelve fold assignments, so the variability of the chosen tuning parameter is visible.
Principal Component RegressionRegress on principal components with each component's variance share printed beside its correlation with the outcome, and the error at every component count.
Multiple RegressionFits several predictors with a VIF on every term, and names the configuration people misread: a model significant at p = 0.0103 where neither predictor reaches 0.05, at a VIF of only 7.11.
VIFVariance inflation factors with Belsley-Kuh-Welsch condition indices and variance-decomposition proportions, so a near-dependency is named rather than only detected.

More in Math, or browse all calculators.

Educational use disclaimer

An educational tool. Lasso selection is unstable under resampling, particularly with correlated predictors, and a selected set should not be reported as a finding about which variables matter. Standard errors and p-values are not provided because selection and estimation used the same data; refitting least squares on the selected predictors and reporting those intervals is invalid for the same reason.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

What's changed (5 updates)

Published 13 September 2026

  1. Published a lasso path with the number of surviving predictors at every penalty.
  2. Resampled the rows sixty times on every run and reported how often each predictor survives.
  3. Showed sixteen distinct predictor sets where the reported one reappears a third of the time.
  4. Contrasted that with prediction error, which varies far less than the selected set does.
  5. Stated why no p-values are offered: selection and estimation used the same data.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.