One-standard-error threshold from five fold errors and the choice of a simpler model

Hastie and colleagues describe a rule often used with cross-validation, which chooses the most parsimonious model whose error is no more than one standard error above the error of the best model. E_1 to E_5 are the best model's errors in five equal folds, E_bar their mean, SS the sum of squared deviations and SE the standard error of the mean across folds, which takes the form of HE-FM-ANTV-002 with folds in place of pairs. T is the threshold, which takes the form of the upper limit U of HE-FM-AN-001 with E_bar as theta_hat and z at 1, used as a selection margin and not read as a confidence limit (derived). The flag keep is 1 when the simpler model's error CV_s is at or below T, so a tie keeps the simpler model, and 0 otherwise. Five folds are written out so that the calculator can run, and the Excel form takes any K.

Signature

E_bar = (E_1 + E_2 + E_3 + E_4 + E_5) / 5; SS = (E_1 - E_bar)^2 + (E_2 - E_bar)^2 + (E_3 - E_bar)^2 + (E_4 - E_bar)^2 + (E_5 - E_bar)^2; SE = sqrt(SS / (4 * 5)); T = E_bar + SE; keep = CV_s <= T
Inputs
InputsDefinitionUnit
E_1Mean held-out loss of the model with the lowest cross-validated error, in fold 1loss unit, for example pounds per patient
E_2Mean held-out loss of the model with the lowest cross-validated error, in fold 2loss unit, for example pounds per patient
E_3Mean held-out loss of the model with the lowest cross-validated error, in fold 3loss unit, for example pounds per patient
E_4Mean held-out loss of the model with the lowest cross-validated error, in fold 4loss unit, for example pounds per patient
E_5Mean held-out loss of the model with the lowest cross-validated error, in fold 5loss unit, for example pounds per patient
CV_sCross-validation estimate of prediction error of the more parsimonious candidate, on the same folds and loss as the best modelloss unit
Output
E_barMean of the five fold errors of the best model, its cross-validation estimate when the folds are equal in sizeloss unit
SSSum of the squared deviations of the five fold errors from E_barloss unit squared
SESample standard deviation of the fold errors divided by the root of the number of folds, here the root of SS / (4 * 5)loss unit
TBest error plus one standard error, the highest error at which a simpler model is keptloss unit
keepResult of the rule, 1 when CV_s is at or below T and 0 when it is aboveflag, 1 or 0

Function

K-fold cross-validation estimate of prediction error and the one-standard-error rule

Maps outcomes, predictors, a fold allocation kappa and a loss function to the K-fold cross-validation estimate of prediction error, the mean loss over all observations when each prediction comes from a model fitted with that observation's fold removed. A second mapping takes the best model's fold errors and a simpler model's error and returns the one-standard-error choice between them, and its threshold takes the form of the upper limit U of HE-FM-AN-001 with z at 1 (derived). Once predictions are given, the averaging step takes the MAE form of HE-FM-DFC-003, or the form of HE-FN-BRIER-001 for squared error on predicted risks, and these records add the refit. HE-AS-BRIER-002 and HE-AS-DCA-003 name cross-validation as a correction for optimistic performance in development data. The article's second equation, the mean of the fold mean losses weighted by fold size, takes the form of the size-weighted mean HE-FM-CRAT-001 and of the first part of HE-FM-CWT-001 and has no record of its own; on the article's illustrative table it returns 1,000.8 for Model A and 1,078.6 for Model B. Hastie and colleagues report Stone's 1977 result that AIC, HE-FM-AIC-001, and leave-one-out cross-validation are asymptotically equivalent. The other use of the word, comparing one decision model's results with those of other models, has no formula here. Notation follows the Cross-Validation article.

Try this function

Implementations

  • Excel

    Excel one-standard-error threshold from a range of fold errors

    With the best model's fold errors in a range named FoldErrorsBest and the simpler model's error in SimplerCvError, the four formulas return BestCvError, StdErrBest, OneSeThreshold and KeepSimpler in that order. AVERAGE, VAR and COUNT ignore blank cells, so a missing fold shortens the range without warning, and one fold alone returns #DIV/0! from VAR. KeepSimpler returns TRUE or FALSE, where the calculator returns 1 or 0.

    =AVERAGE(FoldErrorsBest); =SQRT(VAR(FoldErrorsBest)/COUNT(FoldErrorsBest)); =BestCvError+StdErrBest; =SimplerCvError<=OneSeThreshold

Assumptions

  • Best model named before the rule and candidates ranked by parsimony

    The fold errors belong to the candidate with the lowest cross-validated error, and CV_s belongs to a more parsimonious candidate, so CV_s is at least E_bar. Candidates are scored on the same folds and loss (derived; a different allocation adds a difference that is not due to the models). Parsimony is a judgement outside the formula, such as fewer predictors or a heavier penalty. With several simpler candidates the rule picks the most parsimonious one that keeps its flag at 1.

  • Fold errors of equal fold size treated as independent values

    Equal folds make E_bar the cross-validation estimate of HE-FM-CROV-001, and they reduce the glmnet package's fold-level standard error to the sample standard deviation over the root of K (derived, 0 mismatches on a grid of 10,000 draws). Unequal folds call for the fold weights that glmnet uses. The formula treats fold errors as independent, whereas Bates and colleagues state that each data point is used for both training and testing and that there are correlations among the measured accuracies for each fold, so the usual estimate of variance is too small. SE is therefore a working margin and not an exact standard error.

  • Rule read from the text of Hastie and colleagues with a weak inequality

    The words no more than one standard error above give a weak inequality, so CV_s equal to T keeps the simpler model. Hastie and colleagues describe the standard error bars as the standard errors of the individual misclassification error rates for each of the ten parts, and in section 3.3.4 as based on the ten error estimates computed by cross-validation. The record takes the calculation from the glmnet code, which at equal fold sizes is the sample standard deviation of the fold errors over the root of K (derived).

Worked examples

  • Simpler cost model within one standard error of the best

    Illustrative inputs. The best model has errors of 1,000, 940, 1,060, 980 and 1,020 pounds per patient in five equal folds, a mean of 1,000 and a standard error of 20, so the threshold is 1,020. A simpler model at 1,015 pounds is kept although it is 15 pounds worse.

    E_1 = 1000; E_2 = 940; E_3 = 1060; E_4 = 980; E_5 = 1020; CV_s = 1015; E_bar = 1000; SS = 8000; SE = 20; T = 1020; keep = 1
  • Simpler cost model beyond one standard error of the best

    Illustrative inputs. The same fold errors with a simpler model at 1,030 pounds per patient. The simpler model is above the threshold of 1,020 pounds, so the best model stays.

    E_1 = 1000; E_2 = 940; E_3 = 1060; E_4 = 980; E_5 = 1020; CV_s = 1030; E_bar = 1000; SS = 8000; SE = 20; T = 1020; keep = 0
  • Simpler cost model exactly at the one-standard-error threshold

    Illustrative tie. The same fold errors with a simpler model at exactly 1,020 pounds per patient. Its error is no more than one standard error above the best, so it is kept.

    E_1 = 1000; E_2 = 940; E_3 = 1060; E_4 = 980; E_5 = 1020; CV_s = 1020; E_bar = 1000; SS = 8000; SE = 20; T = 1020; keep = 1

Common errors

  • Reporting the minimum cross-validated error as the expected error

    Taking the lowest cross-validated error among tuned candidates as the error to expect is optimistic. The one-standard-error rule changes which model is chosen and leaves that minimum as it was (derived). Varma and Simon, tuning classifiers, conclude that the minimum CV error estimate is not an unbiased estimate of the true error on independent data and that the difference can be greater than 20% more than one-fifth of the time. They report that a nested procedure, tuning in an inner loop and estimating error in an outer loop, gives an estimate very close to that from an independent test set.

  • Standard deviation of fold errors used as the margin

    Adding the standard deviation of the fold errors, without dividing by the root of K, widens the margin. In HE-EX-CROV-005 it gives a threshold of 1,044.72 in place of 1,020, so the simpler model at 1,030 pounds is wrongly kept (derived).

  • Applying the rule by default when the aim is prediction

    The rule favours parsimony, which does not always help prediction. Chen and Yang, studying the rule mainly for the Lasso in regression, report that it tends to outperform regular cross-validation in sparse variable selection and often performs worse in regression estimation or prediction, and that its standard error estimate can be biased by 50 to 100% upwards or downwards.

Sources

  • Hastie, Tibshirani and Friedman on the one-standard-error rule

    Hastie T, Tibshirani R, Friedman J. The Elements of Statistical Learning. 2nd ed. New York: Springer; 2009. 12th printing, authors' PDF. Section 7.10.1, page 244, in the text following Figure 7.9, states that a one-standard error rule is often used with cross-validation, choosing the most parsimonious model whose error is no more than one standard error above the error of the best model, and describes the error bars as the standard errors of the individual misclassification error rates for each of the ten parts. Section 3.3.4, page 61, includes estimated standard error bands for each estimated error rate, based on the ten error estimates computed by cross-validation, and picks the most parsimonious model within one standard error of the minimum.

    View source →

  • glmnet package code for the fold-level cross-validation standard error

    Friedman J, Hastie T, Tibshirani R, et al. glmnet: Lasso and Elastic-Net Regularized Generalized Linear Models. R package version 5.2, dated 26 October 2026, CRAN mirror source files. In R/cvstats.R the value cvsd is the square root of the weighted mean of squared deviations of cvraw from cvm, divided by N-1, and in R/cvcompute.R cvraw holds the per-fold weighted means and N counts the folds with results. The cv.glmnet help describes cvsd as the estimate of standard error of cvm and lambda.1se as the largest lambda whose error is within 1 standard error of the minimum.

    View source →

  • Chen and Yang on whether the one-standard-error rule works

    Chen Y, Yang Y. The one standard error rule for model selection: does it work? Stats. 2021;4(4):868-892. doi:10.3390/stats4040051. The abstract describes the rule as selecting the most parsimonious model whose prediction error is not much worse than the minimum CV error, reports estimation bias of 50 to 100% upwards or downwards in various situations, and reports that the rule tends to outperform regular CV in sparse variable selection and often performs worse in regression estimation or prediction.

    View source →

  • Varma and Simon on bias in the minimum cross-validated error

    Varma S, Simon R. Bias in error estimation when using cross-validation for model selection. BMC Bioinformatics. 2006;7:91. doi:10.1186/1471-2105-7-91. The Conclusion states that the minimum CV error estimate is not an unbiased estimate of the true error and that the difference can be greater than 20% more than one-fifth of the time. The abstract states that the nested CV procedure gives an estimate of the error very close to that obtained on the independent testing set.

    View source →

Canonical Identity

This formula is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

Author: Dr Darrin Baines · Publisher: Intelligent Parameters Ltd · Identifier: https://healtheconomics.wiki/formula/one-standard-error-threshold-from-five-fold-errors-and-the-choice-of-a-simpler-model

One-standard-error threshold from five fold errors and the choice of a simpler model | HealthEconomics.wiki