Concept Architecture
Concept
Theoretically, K-Fold Cross-Validation is a resampling method used to evaluate the predictive performance and generalisability of statistical and machine learning models. The method partitions a dataset into k mutually exclusive subsets (folds), iteratively using one fold for validation and the remaining k ? 1 folds for model training. It exists to provide an unbiased estimate of out-of-sample predictive performance while making efficient use of available data, particularly when sample sizes are limited.
Mathematically, K-Fold Cross-Validation is represented by repeated estimation of a predefined loss function across k validation folds, followed by calculation of the average validation error. The framework estimates the expected prediction error of a modelling procedure rather than the parameters of the model itself. Common loss functions include mean squared error for regression and classification error, log-loss or area under the receiver operating characteristic curve for classification models.
In practice, the dataset is randomly divided into k approximately equal folds, with the model refitted k times. Each observation serves as validation data exactly once and training data k ? 1 times. Performance metrics are averaged across all folds to assess model robustness, compare alternative models and tune hyperparameters. In health economics, K-Fold Cross-Validation is widely applied in predictive risk models, health outcome prediction, resource utilisation forecasting, disease progression modelling and machine learning applications supporting economic evaluation.
Purpose
Used to estimate out-of-sample predictive performance, compare competing models, optimise model complexity, reduce overfitting and assess the generalisability of statistical and machine learning models used in health economics.
Mathematical Formulae
Primary Formula
CV = (1/k) ? ????? L?
where:
- CV = average cross-validation error
- k = number of folds
- L? = validation loss for fold i
Supporting Formulae
Mean Squared Error (regression):
MSE = (1/n) ? ?(y? ? ??)�
Classification Error:
Error = Number of incorrect predictions / Number of observations
Root Mean Squared Error:
RMSE = �MSE
Related Mathematical Methods
- Leave-One-Out Cross-Validation (LOOCV)
- Repeated K-Fold Cross-Validation
- Stratified K-Fold Cross-Validation
- Nested Cross-Validation
- Bootstrap Validation
- Hold-Out Validation
Example
A health economist develops a machine learning model to predict annual hospital expenditure using data from 1,000 patients.
Ten-fold cross-validation is selected (k = 10).
Validation Mean Squared Errors obtained from each fold are:
15.1, 14.7, 15.6, 14.9, 15.2, 14.8, 15.0, 15.3, 14.6 and 15.1.
The overall cross-validation error is:
CV = (15.1 + 14.7 + 15.6 + 14.9 + 15.2 + 14.8 + 15.0 + 15.3 + 14.6 + 15.1) � 10
CV = 15.03
The average validation error indicates the expected predictive performance of the model on unseen healthcare data and can be compared with competing models during model selection.
Excel Implementation
| Function | Example Formula | Health Economics Application |
|---|---|---|
| RAND | =RAND() | Randomly assign observations to folds. |
| RANK | =RANK(A2,$A$2:$A$1001) | Randomise observation ordering before fold assignment. |
| MOD | =MOD(B2,10)+1 | Allocate observations to one of k folds. |
| AVERAGE | =AVERAGE(C2:C11) | Calculate the mean validation error across folds. |
| SUMPRODUCT | =SUMPRODUCT((Actual-Predicted)^2)/COUNT(Actual) | Calculate validation Mean Squared Error for each fold. |
VBA (Optional)
A VBA routine can automate fold generation, iterative model evaluation and calculation of average cross-validation performance across multiple candidate models.
Sources
- Hastie T, Tibshirani R, Friedman J. The Elements of Statistical Learning. Springer.
- James G, Witten D, Hastie T, Tibshirani R. An Introduction to Statistical Learning. Springer.
- Kuhn M, Johnson K. Applied Predictive Modelling. Springer.
- Harrell FE. Regression Modelling Strategies. Springer.
- Briggs A, Claxton K, Sculpher M. Decision Modelling for Health Economic Evaluation. Oxford University Press.
- ISPOR Good Practice Reports.
Related Concepts (2)
Library
Publications
1
Bayesian Methods in Health Economics — Gianluca Baio, 1st Edition ed., 2012 (Chapman & Hall / CRC Press)
An overview of Bayesian statistical methods for the analysis of health economic data, covering economic evaluation concepts, statistical cost-effectiveness analysis, Bayesian computation and MCMC, and applied health economic evaluation.
BookView source →
Frequently Asked Questions (6)
What is k-fold cross-validation?
A technique assessing how well a model generalises by dividing data into equal folds, training on all but one and testing on the rest.
Source: Stone 1974
How does k-fold cross-validation test a model's ability to generalise?
K-fold cross-validation tests how well a model generalises by splitting the data into a number of equal folds, then repeatedly training the model on all the folds but one and testing it on the fold held out. Rotating through until every fold has served as the test set once, it averages the results to estimate performance on unseen data, making fuller use of a limited dataset than a single split allows. This guards against being misled by one lucky or unlucky division. Rotating the held-out test set is its method. Hastie and colleagues (2009) describe this technique.
Source: Hastie et al. 2009
How does k-fold cross-validation work?
K-fold cross-validation works by splitting the data into equal folds, then for each fold in turn, training the model on the remaining folds and evaluating it on that fold, so every observation is used for testing exactly once and for training in the other rounds. The performance measures from the folds are averaged. So k-fold cross-validation works by systematically rotating the held-out test fold across all the folds and averaging the results, which uses all the data for both training and testing across the rounds and yields an estimate of out-of-sample performance that is less dependent on any single split of the data.
Source: Stone 1974
Why is k-fold cross-validation used?
K-fold cross-validation is used to obtain a reliable estimate of how a model will perform on new data, guarding against the over-optimism of in-sample assessment and the variability of a single train-test split, and to compare models or tune their settings. So k-fold cross-validation is used to estimate generalisation performance and to select models or parameters, since averaging over multiple folds gives a more stable estimate than one split and uses the data efficiently, which is why it is a standard method for validating predictive models and choosing among modelling options while avoiding overfitting to a particular partition of the data.
Source: Stone 1974
How is the number of folds chosen in k-fold cross-validation?
The number of folds in k-fold cross-validation is chosen to balance bias and variance and computational cost: more folds mean each training set is larger, reducing bias in the performance estimate but increasing variance and computation, while fewer folds do the reverse. Common choices are five or ten folds. So the number of folds is selected as a trade-off, with five- or ten-fold cross-validation being usual compromises that give reasonably unbiased and stable estimates at manageable cost, and the extreme of using as many folds as observations gives leave-one-out cross-validation, at the cost of high computation and variance.
Source: Stone 1974
How does k-fold cross-validation differ from a single train-test split?
K-fold cross-validation divides the data into several folds and rotates which is held out, averaging performance across all folds, while a single train-test split uses one portion for training and one for testing just once. The cross-validation estimate is more stable and uses the data more fully, whereas a single split can be unrepresentative and wastes the test data for training. So k-fold cross-validation differs from a single split in averaging over multiple partitions, which reduces the dependence of the performance estimate on any one split and makes fuller use of the data, giving a more reliable assessment of generalisation.
Source: Stone 1974
Trust Record
Verified by Dr Darrin Baines
British health economist
Professional identity: darrinbaines.org
Verification date: 17 Dec 2025
Content version: 1.0.0
Canonical Identity
- Term code
- HE-ES-SA-093
Stable URI · Machine-readable · Resolvable · CC BY 4.0