cvms | Cross-Validation for Model Selection
cvms is an R package for cross-validating Gaussian and binomial regression models. It allows for easy model comparison, reporting and further analysis. It contains functionality for validating the best model and creating baseline evaluations of the task at hand. Repeated cross-validation is also supported and recommended.
The folds for the cross-validation can be created with groupdata2::fold.
See examples on the GitHub page:
Here’s a quick code example, that first folds the data (balanced so that there’s a similar number of rows for both diagnoses in every fold and so that each participant only appears in one fold), and then cross-validates a simple Gaussian regression model. The dataset used is the participant.scores dataset included in the package.
cv <- fold(data,
k = 4,
cat_col = 'diagnosis',
id_col = 'participant') %>%
folds_col = '.folds',
REML = FALSE)