Learn R Programming

latrend (version 1.1.0)

latrendCV: Cluster longitudinal data over k folds

Description

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.

Usage

latrendCV(
  method,
  data,
  folds = 10,
  seed = NULL,
  envir = NULL,
  verbose = getOption("latrend.verbose")
)

Arguments

method

The lcMethod object specifying the longitudinal cluster method to apply.

data

A data.frame.

folds

The number of folds. Ten folds by default.

seed

The seed to use. Optional.

envir

The environment in which to evaluate the method arguments. Note that this only applies to data when data is a call.

verbose

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').

Value

A lcModels object of containing the folds training models.

See Also

Other longitudinal cluster fit functions: latrendBatch(), latrendBoot(), latrendRep(), latrend()

Other validation methods: createTestDataFolds(), createTestDataFold(), createTrainDataFolds(), latrendBoot(), lcModel-data-filters

Examples

Run this code
# NOT RUN {
data(latrendData)
method <- lcMethodKML("Y", id = "Id", time = "Time")
model <- latrendCV(method, latrendData, folds = 5)

model <- latrendCV(method, subset(latrendData, Time < .5), folds = 5, seed = 1)
# }

Run the code above in your browser using DataLab