Assuming that we have longitudinal data on pulmonary fibrosis with some patients undergoing transplant while others received medical treatment. Each patient is represented by many rows depending on the time of assessment of the quality of life (qol
) which is our outcome (continuous variable). Among the independent predictors are the following variables and their time of occurrence (as they are time-varying covariates); infarction
, transplant
, and death
.
We decided to categorize each of infarction_time
and transplant_time
into 3 categories (No, recent event (=< 3 months), and old event (> 3 months)) between the independent predictor and qol_assessment_time_months
. Patients who will die will be coded as 0
in qol
column at time of death. Consequently, we will run a repeated measures mixed effects model as shown in the code below, which has a fictitious data sample.
Will our model be valid? I saw this link but it seems to be irrelevant to my current data. Any advice will be greatly appreciated.
library(mmrm);library(sjPlot)
data<-structure(list(serial.id = 1:16, PT_ID = c("PT1", "PT1", "PT1",
"PT1", "PT2", "PT2", "PT2", "PT2", "PT3", "PT3", "PT3", "PT3",
"PT4", "PT4", "PT4", "PT4"), VISIT_No. = c(1L, 2L, 3L, 4L, 1L,
2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), transplant = c(0L,
1L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 1L),
transplant_time_months = c(1.1, 1.1, 1.1, 1.1, 2.1, 2.1,
2.1, 2.1, 2.5, 2.5, 2.5, 2.5, 5.1, 5.1, 5.1, 5.1), transplant_time = c("no",
"recent", "old", "old", "no", "recent", "recent", "recent",
"no", "recent", "old", "old", "no", "no", "no", "recent"),
qol_transplant.time = c(-0.1, 1.4, 3.4, 5.9, -1.1, -0.1,
1, 2.9, -1.5, 1.5, 3.5, 4.5, -4.1, -2.1, -0.1, 1.9), infarction = c(0L,
0L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L
), infarction_time_months = c(2.6, 2.6, 2.6, 2.6, 2.5, 2.5,
2.5, 2.5, 6, 6, 6, 6, 6.5, 6.5, 6.5, 6.5), infarction_time = c("no",
"no", "recent", "old", "no", "no", "recent", "old", "no",
"no", "no", "recent", "no", "no", "no", "recent"), qol_infarction.time = c(-1.6,
-0.1, 1.9, 4.4, -1.5, -0.5, 0.6, 2.5, -5, -2, 0, 1, -5.5,
-3.5, -1.5, 0.5), qol_baseline = c(0.252714351, 0.252714351,
0.252714351, 0.252714351, 0.45024771, 0.45024771, 0.45024771,
0.45024771, 0.435006968, 0.435006968, 0.435006968, 0.435006968,
0.316031834, 0.316031834, 0.316031834, 0.316031834), VISITN = c(1L,
2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L
), qol = c(0.042509539, 0.041262234, 0.798179128, 0.205693285,
0.138904667, 0.268516519, 0.18593854, 0.169571187, 0.127670035,
0.213748462, 0.348524093, 0.170447984, 0.307079441, 0.122826554,
0.068807874, 0), qol_assessment_time_months = c(1, 2.5, 4.5,
7, 1, 2, 3.1, 5, 1, 4, 6, 7, 1, 3, 5, 7), death = c(0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L),
death_time = c("no", "no", "no", "no", "no", "no", "no",
"no", "no", "no", "no", "no", "no", "no", "no", "no"), follow_up_time_months = c(10L,
10L, 10L, 10L, 15L, 15L, 15L, 15L, 12L, 12L, 12L, 12L, 7L,
7L, 7L, 7L)), class = "data.frame", row.names = c(NA, -16L
))
fit <- mmrm( formula = qol ~ transplant+transplant_time + infarction+infarction_time + death+ death_time+ us(VISIT_No. | PT_ID), data = data);tab_model(fit)
### A similar data structure without time-varying covariates was present in
fev_data ## built-in database in mmrm package