Related Experiment Video
Updated: Aug 1, 2025

Author Spotlight: Impact of Intergenic Interactions on Disease-Identifying Dark Biomarkers
Published on: March 1, 2024
nestedcv: an R package for fast implementation of nested cross-validation with embedded feature selection designed
Myles J Lewis1,2, Athina Spiliopoulou3, Katriona Goldmann1,4
1Centre for Experimental Medicine & Rheumatology, William Harvey Research Institute, Barts and The London School of Medicine and Dentistry, Queen Mary University of London, London EC1M 6BQ, UK.
Motivation:
Although machine learning models are commonly used in medical research, many analyses implement a simple partition into training data and hold-out test data, with cross-validation (CV) for tuning of model hyperparameters. Nested CV with embedded feature selection is especially suited to biomedical data where the sample size is frequently limited, but the number of predictors may be significantly larger (P ≫ n).
Results:
The nestedcv R package implements fully nested k × l-fold CV for lasso and elastic-net regularized linear models via the glmnet package and supports a large array of other machine learning models via the caret framework. Inner CV is used to tune models and outer CV is used to determine model performance without bias. Fast filter functions for feature selection are provided and the package ensures that filters are nested within the outer CV loop to avoid information leakage from performance test sets. Measurement of performance by outer CV is also used to implement Bayesian linear and logistic regression models using the horseshoe prior over parameters to encourage a sparse model and determine unbiased model accuracy.
Availability And Implementation:
The R package nestedcv is available from CRAN: https://CRAN.R-project.org/package=nestedcv.
Related Concept Videos
Statistical Software for Data Analysis and Clinical Trials
RACE - Rapid Amplification of cDNA Ends
Improving Translational Accuracy
Biostatistics: Overview
Discrete variables are...
Quantifying and Rejecting Outliers: The Grubbs Test
Introduction to R

