Learn R Programming

latrend (version 1.2.1)

latrend: Cluster longitudinal data

Description

Fit a longitudinal cluster method to the given training data, according to the specification provided by the lcMethod object.

This function runs all steps as part of the method fitting procedure.

Usage

latrend(
  method,
  data,
  ...,
  envir = NULL,
  verbose = getOption("latrend.verbose")
)

Arguments

method

An lcMethod object specifying the longitudinal cluster method to apply, or the name (as character) of an lcMethod subclass. See '>lcMethod for details.

data

The data.frame to which to apply the method. Inputs supported by trajectories() can also be used.

...

Any other arguments to update the lcMethod definition with.

envir

The environment in which to evaluate the method arguments (by compose()). This environment is also used to evaluate the data argument if it is of type 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 lcModel object representing the fitted model.

Details

If a seed value is specified in the lcMethod object or arguments to latrend, this seed is set using set.seed prior to the cluster preparation step.

See Also

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

Examples

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

model <- latrend("lcMethodKML", response = "Y", id = "Id", time = "Time", data = latrendData)

method <- lcMethodKML("Y", id = "Id", time = "Time")
model <- latrend(method, data = latrendData, nClusters = 3)

model <- latrend(method, data = latrendData, nClusters = 3, seed = 1)
# }

Run the code above in your browser using DataLab