The `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"
)

Arguments

ldata

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

sdata

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

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 specifying 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.

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 "2s".

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

# 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