Performs a repeated fit of the specified latrend model on the given data.

latrendRep(
  method,
  data,
  .rep = 10,
  ...,
  .errorHandling = "stop",
  .seed = NULL,
  .parallel = FALSE,
  envir = NULL,
  verbose = getOption("latrend.verbose")
)

Arguments

method

An lcMethod object specifying the longitudinal cluster method to apply, or the name (as character) of the lcMethod subclass to instantiate.

data

The data of the trajectories to which to estimate the method for. Any inputs supported by trajectories() can be used, including data.frame and matrix.

.rep

The number of repeated fits.

...

Any other arguments to update the lcMethod definition with.

.errorHandling

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

.seed

Set the seed for generating the respective seed for each of the repeated fits.

.parallel

Whether to use parallel evaluation. See latrend-parallel.

envir

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.

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 containing the resulting models.

Details

This method is faster than repeatedly calling latrend as it only prepares the data via prepareData() once.

See also

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

Examples

data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
models <- latrendRep(method, data = latrendData, .rep = 5) # 5 repeated runs

models <- latrendRep(method, data = latrendData, .seed = 1, .rep = 3)