# NOT RUN {
# linear mixed-effects model fit with random intercept
fitLME <- lme(sqrt(CD4) ~ obstime + I(obstime ^ 2) + drug : obstime + drug : I(obstime ^ 2),
random = ~ 1 | ID, data = aids)
# Cox proportional hazards model fit with a single time-independent covariate
fitCOX <- coxph(Surv(start, stop, event) ~ drug, data = aids, x = TRUE)
# joint model fit which assumes the Cox proportional hazards model for the survival process
# Use 'max.iter = 5', 'nknot = 3' and the 'PFDS' method to calculate standard
# error estimates as a quick toy example
fitJT.ph <- jmodelTM(fitLME, fitCOX, aids, timeVarY = 'obstime',
control = list(SE.method = 'PFDS', max.iter = 5, nknot = 3))
summary(fitJT.ph)
# }
# NOT RUN {
# joint model fit with the default control
fitJT.ph2 <- jmodelTM(fitLME, fitCOX, aids, timeVarY = 'obstime')
summary(fitJT.ph2)
# joint model fit where the survival and longitudinal processes only share
# the same random effect
fitJT.ph3 <- jmodelTM(fitLME, fitCOX, aids, model = 2, timeVarY = 'obstime')
summary(fitJT.ph3)
# joint model fit which assumes the proportional odds model for the survival process
fitJT.po <- jmodelTM(fitLME, fitCOX, aids, rho = 1, timeVarY = 'obstime')
summary(fitJT.po)
# joint model fit where the survival and longitudinal processes only share
# the same random effect
fitJT.po2 <- jmodelTM(fitLME, fitCOX, aids, model = 2, rho = 1, timeVarY = 'obstime')
summary(fitJT.po2)
# linear mixed-effects model fit with random intercept and random slope
fitLME2 <- lme(sqrt(CD4) ~ drug + obstime + I(obstime ^ 2) + drug : obstime +
drug : I(obstime ^2), random = ~ obstime | ID, data = aids)
# Cox proportional hazards model fit with a time-dependent covariate
fitCOX2 <- coxph(Surv(start, stop, event) ~ drug + as.numeric(drug) : obstime,
data = aids, x = TRUE)
# joint model fit in which \code{timeVarT} must be specified
fitJT.ph4 <- jmodelTM(fitLME2, fitCOX2, aids, timeVarY = 'obstime', timeVarT = 'obstime')
summary(fitJT.ph4)
# }
Run the code above in your browser using DataLab