The `jmwMI` function performs multiple imputation on a dataset containing time-dependent covariates (TDCs) for survival analysis. It imputes missing values in longitudinal biomarkers, applies inverse probability weighting (IPW) for longitudinal variables, and fits a survival model (Cox or Aalen) using the imputed datasets. The function returns the results of the analysis, including model coefficients, variances, and imputed data.

jmwMI(
  ldata,
  sdata,
  M = 5,
  id,
  visitTime,
  timeDep,
  impModel = NULL,
  ipwModel = NULL,
  coxModel = NULL,
  model = "Cox"
)

Arguments

ldata

A data frame containing the longitudinal data (biomarker measurements over time) with columns including the subject ID, visit times, time-dependent covariates, and other relevant data.

sdata

A data frame containing the survival data, including the time-to-event information and the event status.

M

An integer specifying the number of imputations to generate. Default is 5.

id

The name of the variable representing the unique individual ID in both `ldata` and `sdata`.

visitTime

The name of the variable representing the visit time in the longitudinal data (`ldata`).

timeDep

A character vector of the time-dependent variables (biomarkers) in `ldata` that will be imputed.

impModel

A list of imputation models, one for each time-dependent variable in `timeDep`. Each model should be specified using a formula.

ipwModel

A list of models used for calculating inverse probability weights (IPWs) for the time-dependent variables in `timeDep`. Each model should be specified using a formula.

coxModel

A survival model formula for Cox proportional hazards regression, such as `Surv(time, event) ~ x1 + x2 + td(x3)`.

model

A string specifying the type of survival model to fit. Options are `'Cox'` (default) or `'Aalen'`.

Value

A list containing:

res

A summary of the results from the survival model.

coefs

A data frame containing the model coefficients.

vars

A data frame containing the variances of the model coefficients.

nam

A character vector containing the names of the model coefficients.

fitted_model

A list containing the fitted models for each imputation.

imp.data

A list of imputed data for the time-dependent variables.

miss.data

The missing data for the time-dependent variables in the original dataset.

complete_data

A list of completed datasets after imputation.

tname

The name of the time variable in the survival data.

ename

The name of the event variable in the survival data.

method

The method used for the analysis. Always "MIm".

References

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.

Author

Atanu Bhattacharjee, Bhrigu Kumar Rajbongshi and Gajendra Kumar Vishwakarma

Examples

library(survival)
model_wMI<- jmwMI(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)),
                 ipwModel=list(~Z_1+Time+(1|ID),
                               ~Z_1+Time+(1|ID),
                               ~Z_1+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")
#> boundary (singular) fit: see help('isSingular')
model_wMI
#> Fitting two stage joint model :
#> Method:  wMI 
#> Time variable:  survival_time 
#> Event variable:  survival_status 
#> 
#> Fitted model summary:
#>           logHR    SE  CIlow CIupp p-value
#> marker_1 -0.158 0.095 -0.345 0.029   0.097
#> marker_2 -0.064 0.102 -0.263 0.136   0.532
#> marker_3  0.053 0.092 -0.126 0.232   0.562
#> Z_1       0.424 0.241 -0.048 0.896   0.078
#> Z_2       0.113 0.352 -0.577 0.803   0.747