Stratified cross-validation fold generator function, inspired from the caret
Stratified cross-validation fold generator function, inspired from the caret
foldgen(data, nfold =5, stratVar =NULL)
Arguments
data: data frame used in the analysis
nfold: number of k-fold cross validations. Default is 5
stratVar: Stratification Variable. Default is NULL and ID is used for CV
Returns
return data.frame with the fold column attached
Examples
d <- nlmixr2data::theo_sd
d$SEX <-0d$SEX[d$ID<=6]<-1covarsVec <- c("WT")# Stratified cross-validation data with CMTdf1 <- foldgen(d, nfold=5, stratVar="CMT")# Stratified cross-validation data with ID (individual)df2 <- foldgen(d, nfold=5, stratVar=NULL)