knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library("JMbayes2")

Fitting Joint Models with JMbayes2

Univariate

The function that fits joint models in JMbayes2 is called jm(). It has three required arguments, Surv_object a Cox model fitted by coxph() or an Accelerated Failure time model fitted by survreg(), Mixed_objects a single or a list of mixed models fitted either by the lme() or mixed_model() functions, and time_var a character string indicating the name of the time variable in the specification of the mixed-effects models. We will illustrate the basic use of the package in the PBC dataset. We start by fitting a Cox model for the composite event transplantation or death, including sex as a baseline covariate:

pbc2.id$status2 <- as.numeric(pbc2.id$status != 'alive')
CoxFit <- coxph(Surv(years, status2) ~ sex, data = pbc2.id)

We aim to assess the strength of the association between the risk of the composite event and the serum bilirubin levels collected during follow-up. We will describe the patient-specific profiles over time for this biomarker using a linear mixed model, with fixed effects, time, sex, and their interaction, and as random effects, random intercepts, and random slopes. The syntax to fit this model with lme() is:

fm1 <- lme(log(serBilir) ~ year * sex, data = pbc2, random = ~ year | id)

The joint model that links the survival and longitudinal submodels is fitted with the following call to the jm() function:

jointFit1 <- jm(CoxFit, fm1, time_var = "year")
summary(jointFit1)

The output of the summary() method provides some descriptive statistics of the sample at hand, followed by some fit statistics based on the marginal (random effects are integrated out using the Laplace approximation) and conditional on the random effects log-likelihood functions, followed by the estimated variance-covariance matrix for the random effects, followed by the estimates for the survival submodel, followed by the estimates for the longitudinal submodel(s), and finally some information for the MCMC fitting algorithm.

By default, jm() adds the subject-specific linear predictor of the mixed model as a time-varying covariate in the survival relative risk model. In the output, this is named as value(log(serBilir)) to denote that, by default, the current value functional form is used. That is, we assume that the instantaneous risk of an event at a specific time $t$ is associated with the value of the linear predictor of the longitudinal outcome at the same time point $t$.

Standard MCMC diagnostics are available to evaluate convergence. For example, the traceplot for the association coefficient value(log(serBilir)) is produced with the following syntax:

ggtraceplot(jointFit1, "alphas")

and the density plot with the call:

ggdensityplot(jointFit1, "alphas")

Notes

Multivariate

To fit a joint model with multiple longitudinal outcomes, we simply provide a list of mixed models as the second argument of jm(). In the following example, we extend the joint model we fitted above by also including the prothrombin time and the log odds of the presence or absence of ascites as time-varying covariates in the relative risk model for the composite event. Ascites is a dichotomous outcome, and therefore, we fit a mixed-effects logistic regression model for it using the mixed_model() function from the GLMMadaptive package. The use of || in the random argument of mixed_model() specifies that the random intercepts and random slopes are assumed uncorrelated. In addition, the argument which_independent can be used to specify which longitudinal outcomes are to be assumed independent; here, as an illustration, we specify that the first (i.e., serum bilirubin) and second (i.e., prothrombin time) longitudinal outcomes are independent. To assume that all longitudinal outcomes are independent, we can use jm(..., which_independent = "all"). Because this joint model is more complex, we increase the number of MCMC iterations, the number of burn-in iterations, and the thinning per chain using the corresponding control arguments:

fm2 <- lme(prothrombin ~ year * sex, data = pbc2, random = ~ year | id)
fm3 <- mixed_model(ascites ~ year + sex, data = pbc2,
                   random = ~ year || id, family = binomial())

jointFit2 <- jm(CoxFit, list(fm1, fm2, fm3), time_var = "year",
                which_independent = cbind(1, 2),
                n_iter = 12000L, n_burnin = 2000L, n_thin = 5L)
summary(jointFit2)

The survival submodel output now contains the estimated coefficients for value(prothrombin) and value(ascites), as well as parameter estimates for all three longitudinal submodels.

Functional forms

As mentioned above, the default call to jm() includes the subject-specific linear predictors of the mixed-effects models as time-varying covariates in the relative risk model. However, this is just one of the many possibilities for linking longitudinal and survival outcomes. The argument functional_forms of jm() provides additional options. Based on previous experience, two extra functional forms are provided: the time-varying slope and the time-varying normalized area/cumulative effect. The time-varying slope is the first-order derivative of the subject-specific linear predictor of the mixed-effect model with respect to the (follow-up) time variable. The time-varying normalized area/cumulative effect is the integral of the subject-specific linear predictor of the mixed-effect model from zero to the current (follow-up) time $t$ divided by $t$. The integral is the area under the subject-specific longitudinal profile; by dividing the integral by $t$, we obtain the average of the subject-specific longitudinal profile over the corresponding period $(0, t)$.

To illustrate how the functional_forms argument can be used to specify these functional forms, we update the joint model jointFit2 by including the time-varying slope of log serum bilirubin instead of the value and also the interaction of this slope with sex and for prothrombin we include the normalized cumulative effect. For ascites, we keep the current value functional form. The corresponding syntax to fit this model is:

fForms <- list(
  "log(serBilir)" = ~ slope(log(serBilir)) + slope(log(serBilir)):sex,
  "prothrombin" = ~ area(prothrombin)
)

jointFit3 <- update(jointFit2, functional_forms = fForms)
summary(jointFit3)

As seen above, the functional_forms argument is a named list with elements corresponding to the longitudinal outcomes. If a longitudinal outcome is not specified in this list, then the default value functional form is used for that outcome. Each element of the list should be a one-sided R formula in which the functions value(), slope(), and area() can be used. Interaction terms between the functional forms and other (baseline) covariates are also allowed.

Penalized Coefficients using Shrinkage Priors

When multiple longitudinal outcomes are considered with possibly different functional forms per outcome, we require to fit a relative risk model containing several terms. Moreover, it is often of scientific interest to select which terms/functional forms per longitudinal outcome are more strongly associated with the risk of the event of interest. To facilitate this selection, jm() allows penalizing the regression coefficients using shrinkage priors. As an example, we refit jointFit3 by assuming a Horseshoe prior for the alphas coefficients (i.e., the coefficients of the longitudinal outcomes in the relative risk model):

jointFit4 <- update(jointFit3, priors = list("penalty_alphas" = "horseshoe"))
cbind("un-penalized" = unlist(coef(jointFit3)), 
      "penalized" = unlist(coef(jointFit4)))

Apart from the Horseshoe prior, the ridge prior is also provided.



drizopoulos/JMbayes2 documentation built on July 15, 2024, 11:13 p.m.