jm2s.RdThe `jm2s` function performs single imputation for time-dependent covariates (TDCs) in survival analysis. It imputes missing values for longitudinal biomarkers and fits a survival model (Cox or Aalen) using the imputed dataset. The function returns the results of the survival model fitting, including coefficients, variances, and imputed dataset.
jm2s(
ldata,
sdata,
id,
visitTime,
timeDep,
impModel = NULL,
coxModel = NULL,
model = "Cox"
)A data frame containing the longitudinal data (biomarker measurements over time) with columns including the subject ID, visit times, and time-dependent covariates.
A data frame containing the survival data, including the time-to-event information and event status.
The name of the variable representing the unique individual ID in both `ldata` and `sdata`.
The name of the variable representing the visit time in the longitudinal data (`ldata`).
A character vector specifying the time-dependent variables (biomarkers) in `ldata` that will be imputed.
A list of imputation models, one for each time-dependent variable in `timeDep`. Each model should be specified using a formula.
A survival model formula for Cox proportional hazards regression, such as `Surv(time, event) ~ x1 + x2 + td(x3)`.
A string specifying the type of survival model to fit. Options are `'Cox'` (default) or `'Aalen'`.
A list containing:
A summary of the results from the survival model.
A data frame containing the model coefficients.
A data frame containing the variances of the model coefficients.
A character vector containing the names of the model coefficients.
A list containing the fitted models for each imputation.
A list of imputed data for the time-dependent variables.
The missing data for the time-dependent variables in the original dataset.
A list of completed datasets after imputation.
The name of the time variable in the survival data.
The name of the event variable in the survival data.
The method used for the analysis. Always "2s".
Goodrich, B., et al. "rstanarm: Bayesian applied regression modeling via Stan. R package version 2.17. 4." Online< http://mc-stan. org (2018).
Bhattacharjee, A., Rajbongshi, B. K., & Vishwakarma, G. K. (2024). jmBIG: enhancing dynamic risk prediction and personalized medicine through joint modeling of longitudinal and survival data in big routinely collected data. BMC Medical Research Methodology, 24(1), 172.
# Example usage:
library(survival)
#> Warning: package 'survival' was built under R version 4.3.3
model_jm2s<-jm2s(ldata=long_data,sdata=surv_data,
timeDep=c("marker_1","marker_2","marker_3"),
impModel=list(marker_1~Z_1+Z_2+Time+(1|ID),
marker_2~Z_1+Z_2+Time+(1|ID),
marker_3~Z_1+Z_2+Time+(1|ID)),
visitTime="Time",
coxModel=Surv(survival_time,survival_status)~Z_1+Z_2+
td(marker_1)+td(marker_2)+td(marker_3),
model="Cox",
id="ID")
model_jm2s
#> Fitting two stage joint model :
#> Method: 2s
#> Time variable: survival_time
#> Event variable: survival_status
#>
#> Fitted model summary:
#> logHR SE CIlow CIupp p-value
#> marker_1 -0.145 0.091 -0.324 0.033 0.111
#> marker_2 -0.066 0.099 -0.261 0.129 0.509
#> marker_3 0.037 0.089 -0.137 0.211 0.679
#> Z_1 0.416 0.231 -0.037 0.868 0.072
#> Z_2 0.134 0.345 -0.541 0.810 0.697