This function performs the two-stage landmarking analysis.
fit_LME_landmark(
data_long,
x_L,
x_hor,
fixed_effects,
random_effects,
fixed_effects_time,
random_effects_time,
individual_id,
k,
cross_validation_df,
random_slope_in_LME = TRUE,
random_slope_as_covariate = TRUE,
standardise_time = FALSE,
lme_control = nlme::lmeControl(),
event_time,
event_status,
survival_submodel = c("standard_cox", "cause_specific", "fine_gray"),
b
)
Data frame or list of data frames each corresponding to a landmark age x_L
(each element of the list must be named the value of x_L
it corresponds to).
Each data frame contains repeat measurements data and time-to-event data in long format.
Numeric specifying the landmark time(s)
Numeric specifying the horizon time(s)
Vector of character strings specifying the column names in data_long
which correspond to the fixed effects
Vector of character strings specifying the column names in data_long
which correspond to the random effects
Character string specifying the column name in data_long
which contains the time at which the fixed effects were recorded
Vector of character strings specifying the column names in data_long
which contain the times at which repeat measures were recorded. This should either be length 1 or
the same length as random_effects
. In the latter case the order of elements must correspond to the
order of elements in random_effects
.
Character string specifying the column name in data_long
which contains the individual identifiers
Integer specifying the number of folds for cross-validation.
An alternative to setting parameter cross_validation_df
for performing cross-validation; if both are missing no cross-validation is used.
List of data frames containing the cross-validation fold each individual is assigned to. Each data frame in the list should be
named according to the landmark time x_L
that they correspond. Each data frame should contain the columns individual_id
and a column cross_validation_number
which contains the cross-validation fold of the individual. An alternative to setting parameter k
for performing cross-validation;
if both are missing no cross-validation is used.
Boolean indicating whether to include a random slope in the LME model
Boolean indicating whether to include the random slope estimate from the LME model as a covariate in the survival submodel.
Boolean indicating whether to standardise the time variables (fixed_effects_time
and random_effects_time
) by subtracting the mean
and dividing by the standard deviation (see Details section for more information)
Object created using nlme::lmeControl()
, which will be passed to the control
argument of the lme
function
Character string specifying the column name in data_long
which contains the event time
Character string specifying the column name in data_long
which contains the event status (where 0=censoring, 1=event of interest, if there are competing events these are labelled
2 or above).
Character string specifying which survival submodel to
use. Three options: the standard Cox model i.e. no competing risks ("standard_cox"
),
the cause-specific regression model ("cause_specific"
), or the Fine Gray
regression model ("fine_gray"
)
Integer specifying the number of bootstrap samples to take when calcluating standard error of c-index and Brier score
List containing containing information about the landmark model at each of the landmark times.
Each element of this list is named the corresponding landmark time, and is itself a list containing elements:
data
, model_longitudinal
, model_LME
, model_LME_standardise_time
, model_survival
, and prediction_error
.
data
has one row for each individual in the risk set at x_L
and
contains the value of the fixed_effects
using the LOCF approach and predicted values of the
random_effects
using the LME model at the landmark time x_L
. It also includes the predicted
probability that the event of interest has occurred by time x_hor
, labelled as "event_prediction"
.
There is one row for each individual.
model_longitudinal
indicates that the longitudinal approach is LME.
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.
prediction_error
contains a list indicating the c-index and Brier score at time x_hor
and their standard errors if parameter b
is used.
For more information on how the prediction error is calculated
please see ?get_model_assessment
which is the function used to do this within fit_LME_landmark
.
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 use to normalise times when fitting the LME model.
model_survival
contains the outputs from
the survival submodel functions, including the estimated parameters of the model. For a model using cross-validation,
model_survival
will contain a list of outputs with each
element in the list corresponding to a different cross-validation fold.
model_survival
contains the outputs from the function used to fit the survival submodel, including the estimated parameters of the model.
For a model using cross-validation, model_survival
contains a list of outputs with each
element in the list corresponding to a different cross-validation fold. For more information on how the survival model is fitted
please see ?fit_survival_model
which is the function used to do this within fit_LME_landmark
.
prediction_error
contains a list indicating the c-index and Brier score at time x_hor
and their standard errors if parameter b
is used.
Firstly, this function selects the individuals in the risk set at the landmark time x_L
.
Specifically, the individuals in the risk set are those that have entered the study before the landmark age
(there is at least one observation for each of the fixed_effects
andrandom_effects
on or before x_L
) and
exited the study on after the landmark age (event_time
is greater than x_L
).
Secondly, if the option to use cross validation
is selected (using either parameter k
or cross_validation_df
), then an extra column cross_validation_number
is added with the
cross-validation folds. If parameter k
is used, then the function add_cv_number
randomly assigns these folds. For more details on this function see ?add_cv_number
.
If the parameter cross_validation_df
is used, then the folds specified in this data frame are added.
If cross-validation is not selected then the landmark model is
fit to the entire group of individuals in the risk set (this is both the training and test dataset).
Thirdly, the landmark model is then fit to each of the training data. There are two parts to fitting the landmark model: using the longitudinal data and using the survival data.
Using the longitudinal data is the first stage and is performed using fit_LME_longitudinal
. See ?fit_LME_longitudinal
more for information about this function.
Using the survival data is the second stage and is performed using fit_survival_model
. See ?fit_survival_model
more for information about this function.
Fourthly, the performance of the model is then assessed on the set of predictions
from the entire set of individuals in the risk set by calculating Brier score and C-index.
This is performed using get_model_assessment
. See ?get_model_assessment
more for information about this function.
# NOT RUN {
library(Landmarking)
data(data_repeat_outcomes)
data_model_landmark_LME <-
fit_LME_landmark(
data_long = data_repeat_outcomes,
x_L = c(60, 61),
x_hor = c(65, 66),
k = 10,
fixed_effects = c("ethnicity", "smoking", "diabetes"),
fixed_effects_time = "response_time_sbp_stnd",
random_effects = c("sbp_stnd", "tchdl_stnd"),
random_effects_time = c("response_time_sbp_stnd", "response_time_tchdl_stnd"),
individual_id = "id",
standardise_time = TRUE,
lme_control = nlme::lmeControl(maxIter = 100, msMaxIter = 100),
event_time = "event_time",
event_status = "event_status",
survival_submodel = "cause_specific"
)
# }
Run the code above in your browser using DataLab