Apply k-fold cross validation for internal cluster validation. Creates k random subsets ("folds") from the data, estimating a model for each of the k-1 combined folds.
latrendCV(
method,
data,
folds = 10,
seed = NULL,
parallel = FALSE,
errorHandling = "stop",
envir = NULL,
verbose = getOption("latrend.verbose")
)
An lcMethod object specifying the longitudinal cluster method to apply, or the name (as character
) of the lcMethod
subclass to instantiate.
A data.frame
.
The number of folds. Ten folds by default.
The seed to use. Optional.
Whether to enable parallel evaluation. See latrend-parallel. Method evaluation and dataset transformation is done on the calling thread.
Whether to "stop"
on an error, or to "remove'
evaluations that raised an error.
The environment
in which to evaluate the method arguments via compose()
.
If the data
argument is of type call
then this environment is also used to evaluate the data
argument.
The level of verbosity. Either an object of class Verbose
(see R.utils::Verbose for details),
a logical
indicating whether to show basic computation information,
a numeric
indicating the verbosity level (see Verbose),
or one of c('info', 'fine', 'finest')
.
A lcModels
object of containing the folds
training models.
Other longitudinal cluster fit functions:
latrend()
,
latrendBatch()
,
latrendBoot()
,
latrendRep()
Other validation methods:
createTestDataFold()
,
createTestDataFolds()
,
createTrainDataFolds()
,
latrendBoot()
,
lcModel-data-filters
data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
if (require("caret")) {
model <- latrendCV(method, latrendData, folds = 5, seed = 1)
model <- latrendCV(method, subset(latrendData, Time < .5), folds = 5)
}