Performs k-fold cross validation with the Mixed Model Repeated Measures model (see MMRM).
Arguments
- formula
formula for the fixed effects structure of the model
- time
the time variable of the model
- subjects
the variable indicating unique subjects
- data
the data structure
- k
the number of splits for k-fold cross-validation, default = 10
- seed
random seed used to generating splits, If NULL does not set the seed
- in_loop
function to process each split of training set data. See details
- ...
arguments passed to
in_loop
and MMRM
Value
mmrmCV
object: a list of outputs with length k
,
each element is the output of a call to mmrm.
See mmrm and mmrmObject for details
Details
Please see MMRM for details on the model.
mmrm_cv supports fitting each of the k-folds in parallel using foreach::foreach loops. To use multiple cores, please register a parallel backend prior to calling mmrm_cv. Here is an example:
= parallel::makeCluster(n_cores)
cl ::registerDoParallel(cl) doParallel
The in_loop
argument allows users to provide a function that
transforms training set data. This function must:
accept the training set data as its first argument
accept pass through arguments (...)
return the processed data structure with all variables specified in the supplied formula Here is an example
in_loop
that performs no transformations:
= function(data, ...) {
in_loop # do stuff here
return(data)
}