An overview of the latrend package and its capabilities can be found here.
The latrend()
function fits a specified longitudinal cluster method to the given data comprising the trajectories.
This function runs all steps of the standardized method estimation procedure, as implemented by the given lcMethod
object.
The result of this procedure is the estimated lcModel.
latrend(
method,
data,
...,
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.
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
.
Any other arguments to update the lcMethod
definition with.
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 lcModel object representing the fitted solution.
If a seed value is specified in the lcMethod
object or arguments to latrend
, this seed is set using set.seed
prior to the preFit step.
Other longitudinal cluster fit functions:
latrendBatch()
,
latrendBoot()
,
latrendCV()
,
latrendRep()
data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
model <- latrend(method, data = latrendData)
model <- latrend("lcMethodLMKM", formula = Y ~ Time, id = "Id", time = "Time", data = latrendData)
model <- latrend(method, data = latrendData, nClusters = 3, seed = 1)