Thirty observations, eight predictors that all share a common factor, and only the first three matter. Least squares has almost nothing to work with: it returns 2.597 for a predictor whose true coefficient is 1.0, and −0.778 for one whose true coefficient is 0. Ridge pulls everything toward zero — 1.395, 0.676, 0.702 for the three real ones — and that deliberate understatement lowers the cross-validated error from 1.1678 to 0.9092, a 22.14% improvement, at 63.5% total shrinkage. The estimate is more biased and more accurate at the same time.
30 rows · 8 predictors · condition number 22.727 · largest variance inflation 33.06
Penalty 0.05 cuts cross-validated error by 22.14%, at 63.5% shrinkage
Every coefficient is pulled toward zero, which makes the estimate more biased than least squares by construction, and it predicts better anyway. That trade is worth making when the data is thin relative to the number of predictors and they move together — which is exactly what a condition number of 22.73 and a variance inflation of 33.1 describe.
Chosen penalty
0.05
cross-validated error 0.9092
Least squares error
1.1678
22.14% worse
Shrinkage applied
63.5%
of the coefficient norm
Largest variance inflation
33.06
severe collinearity
Every coefficient, pulled in
Least squares and ridge coefficients on the standardised scale, with the original-scale version
Predictor
Least squares
Ridge
Pulled in by
On the original scale
x1
2.5974
1.3946
1.2028
1.07745
x2
0.8167
0.6758
0.1408
0.50480
x3
1.0740
0.7024
0.3716
0.54025
x4
-0.1016
0.3647
-0.2630
0.27685
x5
0.6995
0.6447
0.0547
0.50178
x6
-0.4565
0.3096
0.1469
0.23050
x7
-0.7782
-0.2535
0.5247
-0.20468
x8
-0.0328
-0.0412
-0.0085
-0.03136
Intercept
—
—
—
0.03316
Ridge never sets a coefficient to exactly zero — the penalty is smooth at the origin, so there is no corner for a coefficient to catch on. Everything is kept and everything is reduced, which is a different thing from selection. Averaged over 200 simulated draws, true coefficients of 1.0 come back at about 0.68: that understatement is not a defect but the mechanism.
The whole penalty path
Cross-validated error and coefficient size at each penalty
Penalty
Cross-validated error
Its standard error
Coefficient norm
0.00001
1.16748
0.12289
9.8765
0.0001
1.16494
0.12221
9.8291
0.0005
1.15414
0.11932
9.6256
0.001
1.14162
0.11597
9.3868
0.005
1.06853
0.09852
7.9248
0.01
1.01423
0.09333
6.7528
0.05
0.90922
0.12908
3.6056
lowest error
0.1
0.91077
0.14601
2.6482
0.5
1.03437
0.18972
1.6918
one standard error rule
1
1.21030
0.25358
1.4544
The coefficient norm falls monotonically as the penalty rises, which it must. The error does not: it falls, reaches a minimum, then climbs as the fit is shrunk past usefulness. The one-standard-error rule picks the largest penalty whose error is still within one standard error of the best — here 0.5 — on the argument that a simpler fit should win ties.
At a penalty of zero this is ordinary least squares exactly — the suite confirms the two agree to 0.0e+0 — so the path starts from the unpenalised fit rather than approximating it.
Ridge keeps every predictor. If the goal is to decide which ones matter, lasso sets coefficients to exactly zero — though which ones it picks is far less stable than it looks. The penalty itself is chosen by cross-validation, which is a noisier procedure than a single number suggests.
Bias shown directly Least squares beside it Full penalty path Collinearity measured A plenty-of-data preset
What this tool shows
On the first preset three predictors have a true coefficient of 1.0, and ridge returns 1.395, 0.676 and 0.702. Every estimate is wrong on purpose, and the cross-validated error falls 22.14%. Least squares, with thirty rows and eight collinear predictors, returns 2.597 for one of those same coefficients. Averaged over 200 draws, ridge brings true values of 1.0 back at about 0.68. That understatement is the mechanism, not a defect — and it is entirely a small-sample phenomenon: against a fresh test set ridge beat least squares by 19.83% at thirty rows, 2.35% at sixty, 0.28% at two hundred, and by −0.04% at four hundred.
A penalty path with cross-validated error and its standard error at every point
Least squares beside it, so the shrinkage is visible coefficient by coefficient
The condition number and variance inflation, which say whether ridge has anything to fix
The one-standard-error rule alongside the minimum-error choice
Coefficients on both the standardised and the original scale, with an intercept
A preset with plenty of data where ridge correctly does almost nothing
Bias shown directly Least squares beside it Full penalty path Collinearity measured
Ridge is biased by construction. That is what it is for.
Updated 13 September 2026 · Works in any browser, no installation
Ridge regression adds a penalty on the size of the coefficients, which pulls every estimate toward zero and makes all of them biased — and when predictors are correlated and data is scarce, that reduces total error. Least squares is unbiased, which sounds like the better property and is not the only one: an unbiased estimate with enormous variance is wrong in a different way every time you collect data. Ridge accepts being consistently a little low in exchange for being far less erratic.
At a glance
Formula shown
Ridge minimises ‖y − Xβ‖²/2n + λ‖β‖²/2, giving β = (XᵀX + nλI)⁻¹Xᵀy on standardised predictors. At λ = 0 it is ordinary least squares exactly. As λ rises every coefficient shrinks toward zero and none reaches it, because the squared penalty is smooth at the origin and offers no corner for a coefficient to stop at. The penalty is chosen by cross-validation over a path.
Scenario support
Many predictors relative to observations, predictors that move together (survey items, lagged variables, spectral channels, related financial ratios), any fit where least squares produces coefficients too large or with the wrong sign, and prediction problems where interpreting individual coefficients is not the goal.
Educational estimate
Planning support from the values you enter — not professional advice.
Wrong on purpose, and better for it
The first preset was generated with three predictors whose true coefficients are exactly 1.0 and five whose true coefficients are exactly 0, from thirty observations of eight predictors that all share a common factor.
Least squares has almost nothing to work with. It returns 2.597 for one of the coefficients that should be 1.0, 0.817 for another, and −0.778 for one that should be 0. These are not small errors; with collinear predictors and thirty rows, the fit is chasing noise and reporting it with a straight face.
Ridge returns 1.395, 0.676 and 0.702 for the three real coefficients. Also wrong — and wrong in a systematic direction, all pulled toward zero. Averaged over 200 simulated draws, true values of 1.0 come back at about 0.68, a consistent 32% understatement. That is the bias, it is real, and it does not go away with more draws.
The cross-validated error falls from 1.1678 to 0.9092. A 22.14% improvement, bought with 63.5% shrinkage of the coefficient norm. The estimator that is reliably a bit low beats the one that is unbiased on average and wildly variable in any particular sample.
This is what the bias-variance trade means in practice, and it is worth seeing as numbers rather than as a curve in a textbook. “Unbiased” is a statement about the average across datasets you will never collect. You have one dataset.
When it stops helping
The advantage is not a property of ridge; it is a property of the situation. Holding the design fixed at eight collinear predictors and varying only the sample size, each setting simulated forty times and scored against a fresh six-hundred-row test set:
At twenty-five rows ridge beat least squares by 19.83%, winning on 36 of 40 draws. At thirty, 14.39%. At forty, 6.06%. At sixty, 2.35%. At a hundred, 0.69%. At two hundred, 0.28%. At four hundred, −0.04%— it lost, narrowly.
The second preset is that case made concrete: the same eight predictors with 220 observations. Least squares now returns 0.891, 1.009 and 0.975 for the three true coefficients of 1.0, which is close enough that there is little left to fix. Ridge improves the error by 0.46% and applies only 11.6% shrinkage.
That is the reassuring part of the method. Cross-validation chooses the penalty, so when shrinkage is unnecessary it chooses a small one and the fit converges on least squares. Ridge does not need to be justified in advance; it needs a path and an honest error estimate.
Why standardising is part of the method
The penalty is on the sum of squared coefficients, so it treats a coefficient of 3 as three times more costly than one of 1. But a coefficient depends on the units of its predictor: measure a distance in metres instead of kilometres and its coefficient falls by a factor of a thousand.
Unstandardised, ridge would therefore penalise predictors according to the units someone happened to record them in, which is not a statistical decision anyone intends to make. Every predictor here is centred and scaled to unit standard deviation before fitting, and the coefficients are converted back afterwards, with an intercept, so both scales are available.
The intercept is never penalised. Shrinking it toward zero would mean shrinking the predicted outcome toward zero, which has no motivation at all — it would make the fit depend on whether the outcome happens to be measured in degrees Celsius or Kelvin.
Choosing the penalty
The path table gives cross-validated error at every penalty, with its standard error beside it. The minimum is marked, and so is the one-standard-error choice: the largest penalty whose error is still within one standard error of the best.
That second rule exists because the minimum is not as well determined as it looks. The error curve is usually flat near its bottom, so several penalties are statistically indistinguishable and the one that happens to win is partly an accident of the fold split. When choices tie, the more shrunk fit is the more defensible one.
How unstable that choice is can be measured directly, and the cross-validation page does it: re-drawing the folds on the same data moves the chosen penalty across a tenfold range while the error it achieves varies by about two per cent. Reporting a single optimal penalty as though it were determined by the data overstates what happened.
Ridge against the alternatives
Ridge keeps every predictor. It cannot do otherwise: the squared penalty is smooth at the origin, so there is no corner for a coefficient to catch on, and the path table confirms the count of non-zero coefficients never falls. If the question is which predictors matter, ridge does not answer it.
Lasso does set coefficients to exactly zero, and pays for it: the set it selects is far less reproducible than the coefficients themselves. Elastic net sits between them on a dial.
Where the problem is collinearity specifically rather than too many predictors, component regression attacks it by replacing the predictors with a few directions — which has a failure mode of its own, since the directions carrying the most variance need not be the ones related to the outcome. And the plain diagnostic for collinearity is the variance inflation factor, reported here alongside the condition number.
Reporting it
Report the penalty, how it was chosen, and the cross-validated error at that penalty and at zero. The gap between those two is the entire case for having regularised, and without it a reader cannot tell whether the penalty did anything.
Do not report ridge coefficients as effect estimates. They are shrunk on purpose, by an amount that depends on the penalty and on how collinear the predictors are, so a ridge coefficient is smaller than the effect it estimates and there is no standard error that repairs that. Confidence intervals for penalised coefficients are a live research problem rather than a routine output.
State the condition number or the largest variance inflation factor. They are what justify reaching for a penalised method in the first place, and on data where both are near one the honest report is that least squares was adequate.
Method. Coefficients are obtained in closed form from the penalised normal equations on standardised predictors, with the penalty scaled by n so that a given value means the same thing here as on the lasso and elastic net pages. The suite confirms three exact identities: ridge at a penalty of zero equals ordinary least squares to 0.0e+0; elastic net with no lasso share reproduces this fit to within 1e-8 at four different penalties, which is a coordinate-descent routine agreeing with a matrix inverse; and rescaling a predictor leaves the standardised coefficients unchanged while rescaling the original-scale one by exactly the same factor. It further checks that the coefficient norm falls monotonically along the path and that no coefficient ever reaches zero. 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:
Lasso RegressionFit a lasso across a penalty path with cross-validation, and see how often each selected predictor survives when the rows are resampled.
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.
VIFVariance inflation factors with Belsley-Kuh-Welsch condition indices and variance-decomposition proportions, so a near-dependency is named rather than only detected.
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.
An educational tool. Ridge coefficients are biased toward zero by design and should not be reported as effect estimates; valid confidence intervals for penalised coefficients require methods beyond the scope of this page. The advantage over least squares depends on sample size and collinearity and can be negligible or slightly negative when data is plentiful.