# \donttest{
# linear mixed model fits
fit_lme1 <- lme(log(serBilir) ~ year:sex + age,
random = ~ year | id, data = pbc2)
fit_lme2 <- lme(prothrombin ~ sex,
random = ~ year | id, data = pbc2)
# cox model fit
fit_cox <- coxph(Surv(years, status2) ~ age, data = pbc2.id)
# joint model fit
fit_jm <- jm(fit_cox, list(fit_lme1, fit_lme2), time_var = "year",
n_chains = 1L, n_iter = 11000L, n_burnin = 1000L)
# coef(): fixed effects for the event process
coef(fit_jm)
# fixef(): fixed effects for the first linear mixed submodel
fixef(fit_jm, outcome = 1)
# ranef(): random effects from all linear mixed submodels
head(ranef(fit_jm))
# terms(): random effects terms for the first linear mixed submodel
terms(fit_jm, process = "longitudinal", type = "random")[[1]]
# mode.frame(): model frame for the fixed effects in the second
# linear mixed submodel
head(model.frame(fit_jm, process = "longitudinal", type = "fixed")[[2]])
# model.matrix(): fixed effects design matrix for the first linear
# mixed submodel
head(model.matrix(fit_jm)[[1]])
# family(): family objects from both linear mixed submodels
family(fit_jm)
# compare_jm(): compare two fitted joint models
fit_lme1b <- lme(log(serBilir) ~ 1,
random = ~ year | id, data = pbc2)
fit_jm2 <- jm(fit_cox, list(fit_lme1b, fit_lme2), time_var = "year",
n_chains = 1L, n_iter = 11000L, n_burnin = 1000L)
compare_jm(fit_jm, fit_jm2)
# }
Run the code above in your browser using DataLab