fit_LME_longitudinal {Landmarking} | R Documentation |
Fit a landmarking model using a linear mixed effects (LME) model for the longitudinal submodel
Description
This function is a helper function for fit_LME_landmark
.
Usage
fit_LME_longitudinal(
data_long,
x_L,
fixed_effects,
random_effects,
fixed_effects_time,
random_effects_time,
standardise_time = FALSE,
random_slope_in_LME = TRUE,
random_slope_as_covariate = FALSE,
cv_name = NA,
individual_id,
lme_control = nlme::lmeControl()
)
Arguments
data_long |
Data frame containing repeat measurement data and time-to-event data in long format. |
x_L |
Numeric specifying the landmark time(s) |
fixed_effects |
Vector of character strings specifying the column names in |
random_effects |
Vector of character strings specifying the column names in |
fixed_effects_time |
Character string specifying the column name in |
random_effects_time |
Vector of character strings specifying the column names in |
standardise_time |
Boolean indicating whether to standardise the time variable by subtracting the mean and dividing by the standard deviation (see Details section for more information) |
random_slope_in_LME |
Boolean indicating whether to include a random slope in the LME model |
random_slope_as_covariate |
Boolean indicating whether to include the random slope estimate from the LME model as a covariate in the survival submodel. |
cv_name |
Character string specifying the column name in |
individual_id |
Character string specifying the column name in |
lme_control |
Object created using |
Details
For an individual i
, the LME model can be written as
Y_i = X_i \beta + Z_i U_i + \epsilon_i
where
-
Y_i
is the vector of outcomes at different time points for the individual -
X_i
is the matrix of covariates for the fixed effects at these time points -
\beta
is the vector of coefficients for the fixed effects -
Z_i
is the matrix of covariates for the random effects -
U_i
is the matrix of coefficients for the random effects -
\epsilon_i
is the error term, typically from N(0,\sigma
)
By using an LME model to fit repeat measures data we can allow measurements from the same individuals to be more similar than measurements from different individuals. This is done through the random intercept and/or random slope.
Extending this model to the case where there are multiple random effects, denoted k
, we have
Y_{ik} = X_{ik} \beta_k + Z_{ik} U_{ik} + \epsilon_{ik}
Using this model we can allow a certain covariance structure within the random effects term U_{ik}
, for example a sample from the
multivariate normal (MVN) distribution MVN(0,\Sigma_u)
. This covariance structure means the value of one random effects variable informs about the
value of the other random effects variables, leading to more accurate predictions and allowing there to be missing data in the
random effects variables.
The function fit_LME_landmark
uses a unstructured covariance for the random effects when fitting the LME model (i.e. no constraints are imposed on the values).
To fit the LME model the function lme
from the package nlme
is used.
The fixed effects are calculated as the LOCF for the variables fixed_effects
at the landmark age x_L
and the random effects
are those stated in random_effects
and at times random_effects_time
. The random intercept is always included in the LME model.
Additionally, the random slope can be included in the LME model using the parameter random_slope_in_LME=TRUE
. The model is used to predict the
values of the random effects at the landmark time x_L
,
and these are used as predictors in the survival model along with the LOCF values of the fixed effects.
Additionally, the estimated value of the random slope can
be included as predictors in the survival model using the parameter random_slope_as_covariate=TRUE
.
It is important to distinguish between the validation set and the development set for fitting the LME model. The development set includes
all the repeat measurements (including those after the landmark age x_L
). Conversely, the validation set only includes
the repeat measurements recorded up until and including the landmark age x_L
.
There is an important consideration about fitting the linear mixed effects model. As the variable random_effects_time
gets further from 0, the random effects coefficients get closer to 0. This causes computational issues
as the elements in the covariance matrix of the random effects, \Sigma_u
, are constrained to
be greater than 0. Using parameter standard_time=TRUE
can prevent this issue by standardising the
time variables to ensure that the random_effects_time
values are not too close to 0.
The LOCF values for the fixed effects and the prediction of the random effects at the landmark age
are used as the covariates for the survival submodel, in addition to the estimated random slopes
if option random_effects_as_covariate
is selected.
Value
List containing elements:
data_longitudinal
, model_longitudinal
, model_LME
, and model_LME_standardise_time
.
data_longitudinal
has one row for each individual in the risk set at x_L
and
contains the value of the covariates at the landmark time x_L
of the fixed_effects
using the LOCF model and
random_effects
using the LME model.
model_longitudinal
indicates that the LME approach is used.
model_LME
contains the output from
the lme
function from package nlme
. For a model using cross-validation,
model_LME
contains a list of outputs with each
element in the list corresponds to a different cross-validation fold.
model_LME_standardise_time
contains a list of two objects mean_response_time
and sd_response_time
if the parameter standardise_time=TRUE
is used. This
is the mean and standard deviation used to normalise times when fitting the LME model.