Tutorials › Regression Analysis (Undergraduate) › Minimum Error and the One-Standard-Error Rule

Ridge and Lasso Regression · Tutorial 679 of 991

Minimum Error and the One-Standard-Error Rule

Compare the penalty that minimizes cross-validation error with the largest penalty whose error remains within one estimated standard error of the minimum.

Advanced 10 min read

What You'll Learn

  • Define the minimum-error penalty and the one-standard-error threshold.
  • Calculate a standard error from fold-specific cross-validation losses.
  • Select the largest qualifying penalty from a candidate grid.
  • Compare the prediction and shrinkage tradeoffs of the two choices.
  • Explain why the one-standard-error rule is not a significance test or a guarantee of equal predictive performance.

Why There Can Be More Than One Reasonable Penalty

Cross-validation compares candidate penalty values by measuring prediction error on observations not used to fit each fold-specific model. The penalty with the smallest average error is a direct choice if the sole aim is to minimize the observed cross-validation error. But small differences in those averages can be unstable: another set of folds might produce a slightly different ordering. The one-standard-error rule offers a conservative alternative. It treats penalties with errors close to the minimum as practically competitive, then favors stronger shrinkage among them.

This is a choice between two tuning criteria, not a claim that one penalty is universally best. The minimum-error choice prioritizes the smallest observed cross-validation loss. The one-standard-error choice accepts a loss that is within a specified margin of that minimum in exchange for a larger penalty, which generally shrinks coefficients more strongly. For lasso, stronger shrinkage often also means fewer nonzero coefficients; for ridge, it reduces coefficient magnitudes but does not ordinarily set them exactly to zero.

Definition: For each candidate penalty \(\lambda\), let \(\widehat{R}_{CV}(\lambda)\) be its mean cross-validation loss, calculated by averaging the held-out losses across folds. The minimum-error choice is a candidate \(\lambda_{\min}\) with the smallest \(\widehat{R}_{CV}(\lambda)\). If \(SE_{\min}\) is the estimated standard error of that minimum's cross-validation error, the one-standard-error threshold is \(\widehat{R}_{CV}(\lambda_{\min})+SE_{\min}\). The one-standard-error choice is the largest candidate \(\lambda\) whose mean cross-validation loss is no greater than this threshold.

Calculating the Threshold

Suppose \(K\)-fold cross-validation produces fold losses \(L_1(\lambda),\ldots,L_K(\lambda)\) for a candidate \(\lambda\). In the common simple calculation, their mean is the cross-validation error and their sample standard deviation divided by \(\sqrt K\) estimates its standard error:

$$ \widehat{R}_{CV}(\lambda)=\frac{1}{K}\sum_{k=1}^{K}L_k(\lambda), \qquad SE(\lambda)=\frac{s_L(\lambda)}{\sqrt K} $$

Here \(s_L(\lambda)\) is the sample standard deviation of the \(K\) fold losses. The one-standard-error rule uses \(SE(\lambda_{\min})\), the estimated standard error at the minimum-error candidate, to set the threshold. It does not add a separate standard error to every candidate's loss. Implementations and cross-validation designs can estimate uncertainty differently, so the calculation method should be stated when results are reported. The examples here use this common fold-based calculation.

A short justification clarifies what the calculation does and does not say. If the fold losses are viewed as \(K\) values whose average estimates the cross-validation error, their sample standard deviation describes their observed spread. Dividing by \(\sqrt K\) estimates the standard error of that average under the usual independent, comparable-replicate calculation. This is a useful summary of variation across folds, but folds share much of their training data; therefore this estimate is not a guarantee of precise uncertainty quantification or a formal test of equal predictive performance.

$$ \text{one-SE threshold} = \widehat{R}_{CV}(\lambda_{\min})+SE(\lambda_{\min}) $$

The direction of the choice matters. The rule selects the largest qualifying \(\lambda\), not the smallest one. In ridge and lasso regression, increasing \(\lambda\) increases the penalty and generally strengthens shrinkage. The choice is made from the candidate grid that was evaluated: it does not imply that an untested penalty has been checked.

Worked Example: Finding the Largest Qualifying Penalty

Suppose five-fold cross-validation gives the following mean losses on a fixed candidate grid. Assume all candidates used the same folds and the same loss measure.

Candidate \(\lambda\)Mean cross-validation loss
0.0111.40
0.110.20
19.79
109.72
1009.84

The minimum mean loss is 9.72, at \(\lambda_{\min}=10\). Suppose the five fold losses at this candidate are 9.2, 9.8, 10.1, 9.5, and 10.0. Their mean is

$$ \frac{9.2+9.8+10.1+9.5+10.0}{5} = \frac{48.6}{5} = 9.72. $$

The deviations from 9.72 are \(-0.52, 0.08, 0.38, -0.22,\) and \(0.28\). Thus the sample variance and standard deviation are

$$ s_L^2 = \frac{(-0.52)^2+(0.08)^2+(0.38)^2+(-0.22)^2+(0.28)^2}{5-1} = \frac{0.548}{4} = 0.137, \qquad s_L=\sqrt{0.137}\approx 0.3701. $$

The estimated standard error is \(0.3701/\sqrt{5}\approx 0.1655\), so the threshold is \(9.72+0.1655=9.8855\). The candidates with mean loss no greater than 9.8855 are 1, 10, and 100. Therefore \(\lambda=100\) is the one-standard-error choice: it is the largest qualifying candidate on the listed grid. The minimum-error choice remains \(\lambda=10\).

What the Two Choices Trade Off

The minimum-error penalty optimizes the observed average loss among the candidates tested. It may be preferable when prediction performance is the main priority and the minimum is meaningfully lower than the alternatives. But it can also be a relatively weak penalty selected because of small fluctuations in fold losses. The one-standard-error choice is deliberately more regularized when a larger candidate remains within the threshold. That may yield a simpler lasso fit or stronger coefficient shrinkage, while accepting a cross-validation loss that is close to the observed minimum.

“Close” here has a specific operational meaning: the difference in mean cross-validation loss is at most the estimated standard error used in the rule. It does not mean the two models have been proved equivalent, nor does it establish that their future prediction errors will differ by no more than that amount. Cross-validation estimates performance for a specified loss and validation design; the selected penalty depends on those choices.

Worked Example: A Lasso Choice With Fewer Active Predictors

A hypothetical lasso analysis evaluates the candidate penalties in the table below. The reported active-predictor count is the number of fitted coefficients that are nonzero at that candidate. Suppose the five fold losses at \(\lambda=0.1\), the minimum-error candidate, are 4.8, 5.0, 5.2, 4.9, and 5.1.

\(\lambda\)Mean cross-validation lossNonzero predictors
0.055.1218
0.15.0014
0.25.0310
0.45.066
0.85.093

The losses at \(\lambda=0.1\) average to \(25.0/5=5.00\). Their deviations from the mean are \(-0.2, 0, 0.2, -0.1,\) and \(0.1\), giving

$$ s_L = \sqrt{\frac{0.04+0+0.04+0.01+0.01}{4}} = \sqrt{0.025} \approx 0.1581, \qquad SE_{\min} = \frac{0.1581}{\sqrt{5}} \approx 0.07071. $$

The one-standard-error threshold is \(5.00+0.07071=5.07071\). The largest candidate not exceeding it is \(\lambda=0.4\), with mean loss 5.06; \(\lambda=0.8\) does not qualify because its loss is 5.09. On this grid, the minimum-error fit has 14 nonzero predictors, while the one-standard-error fit has 6. The latter is more sparse in this example, but its cross-validation loss is 0.06 higher. That is an observed tradeoff, not proof that either fit will be better on future data.

Apply the Rule to the Candidate Grid

The one-standard-error rule does not require the cross-validation curve to decrease smoothly on one side of the minimum and increase smoothly on the other. Fold variation can make nearby values rise and fall. The rule is therefore best applied by calculating the threshold, comparing every candidate with it, and choosing the largest candidate that qualifies. Do not infer eligibility merely from the position of a candidate next to the minimum.

Worked Example: Checking Every Candidate on a Nonmonotone Curve

Suppose the minimum mean cross-validation loss is 12.32 at \(\lambda=2\). Its five fold losses are 11.8, 12.1, 13.0, 12.5, and 12.2. Their sum is 61.6, so their mean is \(61.6/5=12.32\). The deviations are \(-0.52,-0.22,0.68,0.18,-0.12\); hence

$$ s_L = \sqrt{\frac{0.2704+0.0484+0.4624+0.0324+0.0144}{4}} = \sqrt{0.207} \approx 0.4550, \qquad SE_{\min} = \frac{0.4550}{\sqrt{5}} \approx 0.2035. $$

The threshold is \(12.32+0.2035=12.5235\). Compare it with every candidate:

\(\lambda\)Mean cross-validation lossAt or below 12.5235?
0.512.60No
112.45Yes
212.32Yes
412.50Yes
812.48Yes
1612.70No

Although the candidate at \(\lambda=16\) is beyond the threshold, \(\lambda=8\) qualifies. The largest qualifying candidate is therefore \(\lambda=8\), not \(\lambda=4\) and not 16. This illustrates why the rule calls for checking the full tested grid rather than assuming that qualifying candidates form a continuous interval.

Interpreting and Reporting the Decision

The rule is a practical selection convention, not a hypothesis test. It does not define \(H_0\) and \(H_a\), use a significance level \(\alpha\), or yield a p-value. In particular, being within one standard error is not evidence that two penalties have identical predictive performance. Nor is the standard error a confidence interval for the penalty parameter. It summarizes estimated variation in the cross-validation loss according to the calculation used.

A clear report names both choices and provides enough information to reconstruct the decision: the candidate grid, the loss measure, the minimum cross-validation loss and its penalty, the estimated standard error at that minimum, the resulting threshold, and the largest qualifying penalty. For the one-standard-error choice, it is also useful to describe the resulting model's degree of shrinkage or, for lasso, its number of nonzero coefficients. Do not call a larger-\(\lambda\) fit “better” without saying in what sense: it may be simpler, while its observed mean loss may be slightly higher.

Key takeaway: Find the minimum cross-validation loss, add its estimated standard error to set a threshold, and select the largest tested \(\lambda\) whose mean loss is at or below that threshold. The minimum-error and one-standard-error choices express different priorities: lowest observed loss versus stronger shrinkage among candidates close to that minimum.

Common Mistakes

  • Choosing the smallest qualifying penalty. The one-standard-error rule chooses the largest qualifying \(\lambda\), because larger penalties generally impose stronger shrinkage.
  • Adding the standard error to every candidate's loss. The stated rule uses the standard error estimated at \(\lambda_{\min}\) to set one threshold for all candidate mean losses.
  • Assuming the cross-validation curve is monotone away from its minimum. Fold variation can produce nonmonotone values, so compare every candidate directly with the threshold.
  • Calling the rule a significance test or proof of equal performance. It is a tuning convention based on an estimated error margin, not a test of a null hypothesis.
  • Reporting a penalty not on the grid as the result. The rule selects among evaluated candidates; it does not establish that untested values meet the threshold.

Check Your Understanding

Answer each question using the definitions and calculations in this tutorial.

  1. A candidate grid has minimum mean cross-validation loss 18.4 at \(\lambda=3\), with \(SE_{\min}=0.6\). What is the one-standard-error threshold?
  2. If candidates \(\lambda=5, 10,\) and \(20\) have mean losses 18.8, 18.9, and 19.2, respectively, which is the one-standard-error choice under the threshold in Question 1?
  3. Why does the one-standard-error rule use the standard error at the minimum-error candidate rather than adding a separate standard error to each candidate's mean loss?
  4. Explain why a one-standard-error choice is not proof that its future prediction error equals that of the minimum-error choice.
  5. For lasso, what tradeoff might arise when the one-standard-error choice has a larger \(\lambda\) than the minimum-error choice?