
Fits the specified longitudinal model for time-varying covariates up to the landmark times
Source:R/longitudinal.R
fit_longitudinal.RdFits the specified longitudinal model for time-varying covariates up to the landmark times
Usage
fit_longitudinal(
x,
landmarks,
method,
formula,
dynamic_covariates,
validation_fold = 0,
cores = getOption("Ncpus", 1L),
.warn_when_prop_few_obs = 0.25,
...
)Arguments
- x
An object of class
LandmarkAnalysis.- landmarks
A vector of Landmark times.
- method
Either
"lcmm"or"lme4"or a function for fitting a longitudinal data model, where the first argument is a formula, and also has adataargument. Only needed for fit-based prediction methods used later inpredict_longitudinal(e.g."lcmm","lme4"); summary measures such as"locf"are computed directly from the data and do not require a call tofit_longitudinal.- formula
A formula to be used in longitudinal sub-model fitting.
- dynamic_covariates
Vector of time-varying covariates to be modelled as the outcome of a longitudinal model.
- validation_fold
If positive, cross-validation fold where model is fitted. If 0 (default), model fitting is performed using the complete dataset.
- cores
Number of cores/threads to be used for parallel computation on Linux and MacOS. Defaults to either
options("Ncpus")if set, or 1 (single threaded) otherwise. Only single-threaded computation is currently supported on Windows.- .warn_when_prop_few_obs
Threshold proportion (0-1) for warning when individuals have 0 or 1 observations. Defaults to 0.25 (i.e., warn when 25% or more individuals have few observations).
- ...
Additional arguments passed to the longitudinal model fitting function (e.g. number of classes/clusters for lcmm).
Value
An object of class LandmarkAnalysis.
See also
lcmm::hlme() and lme4::lmer() for additional arguments.