Fit a list of longitudinal cluster methods on one or more datasets.

latrendBatch(
  methods,
  data,
  cartesian = TRUE,
  seed = NULL,
  parallel = FALSE,
  errorHandling = "stop",
  envir = NULL,
  verbose = getOption("latrend.verbose")
)

Arguments

methods

A list of lcMethod objects.

data

The dataset(s) to which to fit the respective lcMethod on. Either a data.frame, matrix, list or an expression evaluating to one of the supported types. Multiple datasets can be supplied by encapsulating the datasets using data = .(df1, df2, ..., dfN). Doing this results in a more readable call associated with each fitted lcModel object.

cartesian

Whether to fit the provided methods on each of the datasets. If cartesian=FALSE, only a single dataset may be provided or a list of data matching the length of methods.

seed

Sets the seed for generating a seed number for the methods. Seeds are only set for methods without a seed argument or NULL seed.

parallel

Whether to enable parallel evaluation. See latrend-parallel. Method evaluation and dataset transformation is done on the calling thread.

errorHandling

Whether to "stop" on an error, or to "remove' evaluations that raised an error.

envir

The environment in which to evaluate the lcMethod arguments.

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. In case of a model fit error under errorHandling = pass, a list is returned.

Details

Methods and datasets are evaluated and validated prior to any fitting. This ensures that the batch estimation fails as early as possible in case of errors.

See also

lcMethods

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

Examples

data(latrendData)
refMethod <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
methods <- lcMethods(refMethod, nClusters = 1:2)
models <- latrendBatch(methods, data = latrendData)

# different dataset per method
models <- latrendBatch(
   methods,
   data = .(
     subset(latrendData, Time > .5),
     subset(latrendData, Time < .5)
   )
)