Tutorials › Generalized Linear Models › The One-Standard-Error Rule for Penalized Models

Penalized GLM Estimation · Tutorial 916 of 981

The One-Standard-Error Rule for Penalized Models

Use cross-validation uncertainty at the minimum-loss penalty to choose a stronger penalty when its estimated loss remains within one standard error.

Advanced 12 min read

What You'll Learn

  • Define the one-standard-error threshold using cross-validated GLM loss.
  • Calculate the conventional standard error from fold-level losses.
  • Select the largest penalty parameter whose mean loss meets the threshold.
  • Work through loss tables with explicit means and standard errors.
  • Recognize why the rule is a selection heuristic, not a hypothesis test or confidence interval.
  • Avoid comparing candidates to their own standard errors or choosing the weakest eligible penalty.

Why Use a One-Standard-Error Rule?

Cross-validation can identify a penalty value with the smallest estimated prediction loss, but that minimum may be a narrow numerical winner. A nearby, more strongly penalized model may have an estimated loss that is only slightly larger, while using a simpler fit. The one-standard-error rule gives a precise convention for choosing among such candidates: allow loss up to one standard error above the minimum, then select the strongest eligible penalty.

This is a rule for choosing among a specified set of tuning candidates, not a guarantee that the chosen model has the lowest true prediction risk. Its meaning depends on the loss being cross-validated, the folds used, and the convention used to calculate the standard error. In this tutorial, lower loss is better, and “strongest” means the largest value of the penalty parameter \(\lambda\), with other tuning choices held fixed.

Definition and Calculation

Suppose a candidate grid contains penalty values \(\lambda_1,\ldots,\lambda_J\), and cross-validation uses \(K\) folds. Let \(L_k(\lambda_j)\) be the held-out loss for fold \(k\) when the model is fitted with penalty \(\lambda_j\). For example, \(L_k\) could be mean negative log-likelihood or mean deviance on the held-out observations. The loss definition and fold assignments should be consistent across candidates.

Definition: The mean cross-validated loss at \(\lambda_j\) is \(\bar L(\lambda_j)=K^{-1}\sum_{k=1}^K L_k(\lambda_j)\). Let \(\lambda_{\min}\) be a candidate attaining the smallest mean loss. The one-standard-error rule selects the largest candidate penalty \(\lambda_j\) satisfying \(\bar L(\lambda_j)\leq \bar L(\lambda_{\min})+\widehat{\operatorname{SE}}\{\bar L(\lambda_{\min})\}\). With equal-sized folds, the conventional fold-based standard error is \(s_{\min}/\sqrt K\), where \(s_{\min}\) is the sample standard deviation of the \(K\) fold losses at \(\lambda_{\min}\).

Explicitly, the fold-based calculation is

$$ s_{\min} = \sqrt{\frac{1}{K-1}\sum_{k=1}^K \left\{L_k(\lambda_{\min})-\bar L(\lambda_{\min})\right\}^2}, \qquad \widehat{\operatorname{SE}}\{\bar L(\lambda_{\min})\} = \frac{s_{\min}}{\sqrt K}. $$

The rule has two distinct steps. First, find the minimum of the reported mean cross-validation losses and calculate the standard error at that minimum-loss candidate. Second, form the threshold and choose the largest \(\lambda\) whose mean loss is no greater than that threshold. The threshold is inclusive: a candidate exactly on it qualifies.

Why the Fold-Based Standard Error Has This Form

The usual formula \(s/\sqrt K\) is motivated by the standard error of a sample mean. If \(Z_1,\ldots,Z_K\) are independent random variables with a common finite variance \(\tau^2\), then

$$ \operatorname{Var}\left(\frac{1}{K}\sum_{k=1}^K Z_k\right) = \frac{1}{K^2}\sum_{k=1}^K\operatorname{Var}(Z_k) = \frac{\tau^2}{K}. $$

Replacing the unknown \(\tau\) by the sample standard deviation \(s\) gives the conventional estimated standard error \(s/\sqrt K\). In \(K\)-fold cross-validation, however, fold losses are generally dependent: training sets overlap, and the held-out partitions are formed from the same data. Thus this calculation explains the commonly used fold-based estimate; it does not establish that it is an exact standard error under every cross-validation design. Use the standard error reported for the same cross-validation procedure that produced the mean losses, and state the convention if the calculation is being reported.

Worked Example: Computing the Threshold and Selecting a Penalty

Five folds give the following losses for three candidate penalties. The penalty values are ordered from strongest to weakest.

\(\lambda\)Fold lossesMean loss
1.000.590, 0.550, 0.610, 0.570, 0.5800.580
0.500.520, 0.490, 0.540, 0.510, 0.5150.515
0.250.480, 0.530, 0.500, 0.490, 0.5000.500

The mean for \(\lambda=0.25\) is \((0.480+0.530+0.500+0.490+0.500)/5=2.500/5=0.500\), the smallest of the three means. At this penalty, the deviations from the mean are \(-0.020, 0.030, 0, -0.010, 0\). Their squared sum is \(0.0004+0.0009+0+0.0001+0=0.0014\). Therefore,

$$ s_{\min}=\sqrt{\frac{0.0014}{4}}=\sqrt{0.00035}\approx 0.01871, \qquad \widehat{\operatorname{SE}}=\frac{0.01871}{\sqrt{5}}\approx 0.00837. $$

The threshold is \(0.500+0.00837=0.50837\). The loss at \(\lambda=0.50\) is \(0.515\), which exceeds the threshold, and the loss at \(\lambda=1.00\) is \(0.580\), which also exceeds it. The minimum-loss candidate \(\lambda=0.25\) qualifies, so the rule selects \(\lambda=0.25\). It does not select the stronger value \(0.50\), because that value is outside the allowed loss range.

Two Useful Properties of the Rule

The first property confirms that the rule always returns a candidate when the grid is finite and the standard error is nonnegative. The second shows that changing the units of a loss by a positive linear rescaling does not alter the selection.

Result: For a nonempty finite candidate grid, let \(m=\min_j\bar L(\lambda_j)\), and let \(c\geq 0\) be the standard error used at a minimum-loss candidate. The eligible set \(A=\{j:\bar L(\lambda_j)\leq m+c\}\) is nonempty. Consequently, a largest penalty among the eligible candidates exists.

Proof. Since the grid is finite and nonempty, at least one candidate \(j_*\) attains the minimum \(m\). For that candidate, \(\bar L(\lambda_{j_*})=m\leq m+c\), because \(c\geq0\). Thus \(j_*\in A\), so \(A\) is nonempty. It is a subset of a finite grid, so it contains a candidate with the largest \(\lambda\). By construction, that candidate is the strongest eligible penalty. \(\square\)

Result: If every loss is replaced by \(L'_k(\lambda)=a+bL_k(\lambda)\), where \(a\) is any constant and \(b>0\), the one-standard-error rule selects the same penalty, provided the mean and standard error are recalculated from the transformed losses.

Proof. The transformed mean at candidate \(j\) is \(\bar L'(\lambda_j)=a+b\bar L(\lambda_j)\). Because \(b>0\), the candidate means retain their ordering, so the minimum-loss candidate is unchanged (including any ties). Each deviation from the transformed mean is \(b\{L_k(\lambda_{\min})-\bar L(\lambda_{\min})\}\). Hence the transformed sample standard deviation, and its standard error, are \(b\) times the original values. The transformed threshold is therefore

$$ a+b\bar L(\lambda_{\min}) +b\widehat{\operatorname{SE}}\{\bar L(\lambda_{\min})\}. $$

Since \(b>0\), the transformed eligibility inequality is equivalent to the original one: \(a+b\bar L(\lambda_j)\leq a+b\bar L(\lambda_{\min})+b\widehat{\operatorname{SE}}\) if and only if \(\bar L(\lambda_j)\leq\bar L(\lambda_{\min})+\widehat{\operatorname{SE}}\). The eligible candidates, and therefore the selected penalty, are unchanged. \(\square\)

Worked Example: A Stronger Penalty Within One Standard Error

For five folds, suppose the minimum mean loss occurs at \(\lambda=0.10\), with fold losses \(0.28, 0.34, 0.29, 0.31, 0.28\). The mean is \(1.50/5=0.300\). The deviations are \(-0.02, 0.04, -0.01, 0.01, -0.02\), whose squares sum to \(0.0004+0.0016+0.0001+0.0001+0.0004=0.0026\). Thus

$$ s_{\min}=\sqrt{\frac{0.0026}{4}}\approx0.02550, \qquad \widehat{\operatorname{SE}}=\frac{0.02550}{\sqrt{5}}\approx0.01140, \qquad \text{threshold}=0.31140. $$

The candidate means at stronger penalties are \(0.330\) for \(\lambda=0.80\), \(0.308\) for \(\lambda=0.40\), and \(0.303\) for \(\lambda=0.20\). The first is above the threshold; the latter two are below it. The strongest qualifying penalty is therefore \(\lambda=0.40\), even though \(\lambda=0.20\) has a smaller estimated loss. The rule deliberately accepts that small difference in estimated loss in exchange for choosing the larger penalty.

Worked Example: Checking the Boundary of Eligibility

Consider four folds and a minimum-loss candidate \(\lambda=0.20\) with losses \(0.40, 0.42, 0.38, 0.40\). Their mean is \(1.60/4=0.400\). The deviations are \(0, 0.02, -0.02, 0\); the squared deviations sum to \(0.0008\). The sample standard deviation and standard error are

$$ s_{\min}=\sqrt{\frac{0.0008}{3}}\approx0.01633, \qquad \widehat{\operatorname{SE}}=\frac{0.01633}{\sqrt{4}}\approx0.00816. $$

The threshold is approximately \(0.40816\). Suppose the losses for \(\lambda=0.40\) and \(\lambda=0.60\) average \(0.408\) and \(0.409\), respectively, while the loss at \(\lambda=0.80\) is \(0.430\). The \(0.40\) candidate qualifies because \(0.408\leq0.40816\). The \(0.60\) and \(0.80\) candidates do not. Hence \(\lambda=0.40\) is selected. This illustrates why the inequality is inclusive and why rounding the threshold too early can lead to a wrong decision.

Interpretation and Common Pitfalls

For a fixed penalty type and mixing choice, a larger \(\lambda\) applies a stronger penalty in the usual penalized objective. The one-standard-error rule favors such a candidate only when its estimated validation loss is sufficiently close to the minimum. It is a practical selection convention, not a theorem that the selected model is truly simpler in every sense or that its population loss is indistinguishable from the minimum-loss model.

The standard error here measures variability in the estimated cross-validation loss under a particular fold-based convention. The threshold is not a confidence interval for a model’s true prediction loss, and the rule is not a test of whether two models have equal risk. In particular, it does not imply that every eligible candidate is statistically equivalent to the minimum-loss candidate.

  • Using each candidate’s own standard error. The usual rule uses the standard error at the minimum-loss candidate to set one common threshold. Recomputing a different threshold for every candidate changes the rule.
  • Choosing the smallest eligible penalty. That selects the weakest penalty in the eligible set. The rule asks for the strongest, which means the largest \(\lambda\) among eligible candidates.
  • Confusing minimum loss with the final selection. The minimum-loss candidate defines the reference point; it need not be the candidate ultimately selected.
  • Treating the threshold as exact inference. Fold-based standard errors are conventional summaries, and fold losses can be dependent. Do not interpret the one-standard-error band as a guaranteed uncertainty interval.
  • Comparing penalties across different penalty mixtures without a policy. When both the mixing parameter and \(\lambda\) vary, “largest \(\lambda\)” alone may not define a meaningful strongest candidate across the whole grid. Specify a complexity ordering or apply the rule within a fixed mixing choice.

The rule also depends on the candidate grid: it cannot select a penalty that was never evaluated. If the largest penalty in the grid qualifies, the result is the strongest candidate available on that grid, not proof that an even larger penalty would qualify. Report the selected penalty, the minimum-loss penalty, the loss threshold, and the rule used to calculate the standard error so the choice can be understood and reproduced.

Key takeaway: Find the minimum mean cross-validated loss, add one standard error calculated at that minimum, and select the largest penalty whose mean loss does not exceed the resulting threshold.

Check Your Understanding

Use the definition and calculations above to answer these questions.

  1. At which candidate penalty is the standard error for the usual one-standard-error rule calculated?
  2. If the minimum mean loss is \(0.25\) and its estimated standard error is \(0.02\), what is the eligibility threshold?
  3. Two penalties have mean losses \(0.263\) and \(0.270\), and both are within the threshold. Which one is selected if the first penalty is larger?
  4. Why is the fold-based standard error \(s/\sqrt K\) not necessarily an exact standard error for \(K\)-fold cross-validation?
  5. If every loss is multiplied by a positive constant and the standard error is recalculated, does the selected penalty change? Explain briefly.
Clinical Biostats