if (FALSE) {
# linear mixed model fit
fitLME <- lme(sqrt(CD4) ~ obstime * drug - drug,
random = ~ 1 | patient, data = aids)
# cox model fit
fitCOX <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE)
# joint model fit, under the additive log cumulative hazard model
fitJOINT <- jointModel(fitLME, fitCOX,
timeVar = "obstime")
# residuals for the longitudinal outcome
head(cbind(
"Marginal" = residuals(fitJOINT),
"std-Marginal" = residuals(fitJOINT, type = "stand-Marginal"),
"Subject" = residuals(fitJOINT, type = "Subject"),
"std-Subject" = residuals(fitJOINT, type = "stand-Subject")
))
# residuals for the survival outcome
head(cbind(
"Martingale" = residuals(fitJOINT, process = "Event", type = "Martingale"),
"CoxSnell" = residuals(fitJOINT, process = "Event", type = "CoxSnell")
))
}
Run the code above in your browser using DataLab