Functional Forms

Simplified syntax

We have previously seen that function jm() via its functional_forms argument allows the specification of different functional forms to link the longitudinal and event time outcomes. This argument accepts either a single formula or a list of formulas per longitudinal outcome with the terms we wish to include.

We will illustrate some of these possibilities using 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)

Our aim is to assess the strength of the association between the risk of the composite event and whether the patients experienced hepatomegaly during follow-up. We will describe the patient-specific profiles over time for this biomarker using a mixed-effects logistic model, where both in the fixed- and random-effects we include an intercept and the time effect. The syntax to fit this model with mixed_model() is:

fm <- mixed_model(hepatomegaly ~ year, data = pbc2, random = ~ year | id, 
                  family = binomial())

The default call to jm()adds the subject-specific linear predictor of the mixed-effects logistic regression as a time-varying covariate in the survival relative risk model:

jointFit1 <- jm(CoxFit, fm, time_var = "year")
summary(jointFit1)
#> 
#> Call:
#> jm(Surv_object = CoxFit, Mixed_objects = fm, time_var = "year")
#> 
#> Data Descriptives:
#> Number of Groups: 312        Number of events: 169 (54.2%)
#> Number of Observations:
#>   hepatomegaly: 1884
#> 
#>                  DIC     WAIC      LPML
#> marginal    3120.778 3102.739 -1566.649
#> conditional 5207.119 5121.171 -2938.331
#> 
#> Random-effects covariance matrix:
#>                      
#>        StdDev   Corr 
#> (Intr) 3.6028 (Intr) 
#> year   0.6085 -0.2018
#> 
#> Survival Outcome:
#>                        Mean  StDev    2.5%  97.5%      P   Rhat
#> sexfemale           -0.4489 0.3100 -1.0290 0.1882 0.1542 1.0066
#> value(hepatomegaly)  0.3033 0.0511  0.2183 0.4083 0.0000 1.0441
#> 
#> Longitudinal Outcome: hepatomegaly (family = binomial, link = logit)
#>               Mean  StDev    2.5%  97.5%      P   Rhat
#> (Intercept) 0.0756 0.4216 -0.7401 0.9128 0.8618 1.0023
#> year        0.2960 0.1328  0.0376 0.5550 0.0251 1.0035
#> 
#> MCMC summary:
#> chains: 3 
#> iterations per chain: 3500 
#> burn-in per chain: 500 
#> thinning: 1 
#> time: 14 sec

In the output this is named as value(hepatomegaly) to denote that the current value functional form is used. That is, we assume that the risk at a specific time \(t\) is associated with the value of the linear predictor of the longitudinal outcome at the same time point \(t\). In this particular case, the subject-specific linear predictor denotes the log odds of experiencing hepatomegaly at time \(t\).

Transformation functions

The fact that the default version of the current value functional form is on the linear predictor scale of the mixed model may be problematic to interpret when this linear predictor is connected with a nonlinear link function to mean of the longitudinal outcome. In these situations we may want to transform the subject-specific linear predictor back to the scale of the outcome. To achieve this we can use a transformation function. Continuing on the previous example, we update jointFit1 by now linking the expit transformation of the linear predictor (i.e., \(\mbox{expit}(x) = \exp(x) / \{1 + \exp(x)\}\)) with the risk of an event. This is done using the vexpit() function:

jointFit2 <- update(jointFit1, functional_forms = ~ vexpit(value(hepatomegaly)))
summary(jointFit2)
#> 
#> Call:
#> jm(Surv_object = CoxFit, Mixed_objects = fm, time_var = "year", 
#>     functional_forms = ~vexpit(value(hepatomegaly)))
#> 
#> Data Descriptives:
#> Number of Groups: 312        Number of events: 169 (54.2%)
#> Number of Observations:
#>   hepatomegaly: 1884
#> 
#>                  DIC     WAIC      LPML
#> marginal    3106.499 3091.590 -1563.564
#> conditional 5181.813 5126.109 -2896.784
#> 
#> Random-effects covariance matrix:
#>                      
#>        StdDev   Corr 
#> (Intr) 3.6117 (Intr) 
#> year   0.5838 -0.3671
#> 
#> Survival Outcome:
#>                                Mean  StDev    2.5%  97.5%      P   Rhat
#> sexfemale                   -0.3494 0.2782 -0.8719 0.2112 0.2233 1.0011
#> vexpit(value(hepatomegaly))  2.9775 0.4486  2.1586 3.8851 0.0000 1.0338
#> 
#> Longitudinal Outcome: hepatomegaly (family = binomial, link = logit)
#>               Mean  StDev    2.5%  97.5%      P   Rhat
#> (Intercept) 0.0662 0.4269 -0.7598 0.8911 0.8791 1.0041
#> year        0.2424 0.1280 -0.0050 0.4961 0.0556 1.0140
#> 
#> MCMC summary:
#> chains: 3 
#> iterations per chain: 3500 
#> burn-in per chain: 500 
#> thinning: 1 
#> time: 15 sec

Other available functions to use in the definition of the functional_forms argument are vexp() for calculating the exponent, vlog() for calculating the natural logarithm, and vsqrt() for calculating the square root.

If we want to include the time-varying slope of the transformed linear predictor, we also have the Dexpit() and Dexp() functions available. As an example, we extend jointFit2 by including the derivative of the \(\mbox{expit}()\) transformation:

forms <- ~ vexpit(value(hepatomegaly)) + Dexpit(slope(hepatomegaly))
jointFit3 <- update(jointFit1, functional_forms = forms)
summary(jointFit3)
#> 
#> Call:
#> jm(Surv_object = CoxFit, Mixed_objects = fm, time_var = "year", 
#>     functional_forms = forms)
#> 
#> Data Descriptives:
#> Number of Groups: 312        Number of events: 169 (54.2%)
#> Number of Observations:
#>   hepatomegaly: 1884
#> 
#>                  DIC     WAIC      LPML
#> marginal    3106.032 3088.805 -1559.952
#> conditional 5157.634 5091.288 -2889.611
#> 
#> Random-effects covariance matrix:
#>                      
#>        StdDev   Corr 
#> (Intr) 3.6769 (Intr) 
#> year   0.6088 -0.5112
#> 
#> Survival Outcome:
#>                                                    Mean  StDev    2.5%   97.5%
#> sexfemale                                       -0.3383 0.3003 -0.8947  0.2564
#> vexpit(value(hepatomegaly))                      3.0334 0.4753  2.1218  4.0257
#> Dexpit(value(hepatomegaly)):slope(hepatomegaly) -0.8560 0.3695 -1.6331 -0.2087
#>                                                      P   Rhat
#> sexfemale                                       0.2596 1.0037
#> vexpit(value(hepatomegaly))                     0.0000 1.0041
#> Dexpit(value(hepatomegaly)):slope(hepatomegaly) 0.0120 1.0756
#> 
#> Longitudinal Outcome: hepatomegaly (family = binomial, link = logit)
#>               Mean  StDev    2.5%  97.5%      P   Rhat
#> (Intercept) 0.1501 0.4608 -0.7516 1.0587 0.7416 1.0018
#> year        0.1567 0.1341 -0.1018 0.4217 0.2400 1.0097
#> 
#> MCMC summary:
#> chains: 3 
#> iterations per chain: 3500 
#> burn-in per chain: 500 
#> thinning: 1 
#> time: 18 sec

The call to Dexpit(slope(hepatomegaly)) is internally transformed to Dexpit(value(hepatomegaly)):slope(hepatomegaly), which calculates the derivative of the \(\mbox{expit}()\) evaluated at the linear predictor times the derivative of the linear predictor. This is because \[\frac{d}{dt} \mbox{expit}\{\eta(t)\} = \mbox{expit}\{\eta(t)\} \, \Bigl [ 1 - \mbox{expit}\{\eta(t)\} \Bigr ] \times \frac{d}{dt}\eta(t)\]

The Slope functional form

As we have seen in previous examples, the slope() function is used to specify the slope functional form \(d \eta(t)/dt\). According to the definition of the derivative, this corresponds to the change in the longitudinal profile \(\{\eta(t + \varepsilon) - \eta(t)\}/ \varepsilon\) as \(\varepsilon\) approaches zero. However, the interpretation of this term may be challenging in some settings. A possible alternative would be to increase the value of \(\varepsilon\), e.g., \(\varepsilon = 1\). For example, if the time scale is years, this would quantify the change of the longitudinal profile in the last year before \(t\).

To fit a joint model with such a term, we can use the eps and direction arguments of the slope() function. We illustrate this in the following example, in which we use the serum bilirubin

gm <- lme(log(serBilir) ~ ns(year, 2), data = pbc2, random = ~ ns(year, 2) | id,
          control = lmeControl(opt = "optim"))

We first fit the joint model with time-varying slope term:

jFit1 <- jm(CoxFit, gm, time_var = "year",
            functional_forms = ~ value(log(serBilir)) + slope(log(serBilir)))

To specify that we want to include the change in the log serum bilirubin levels during the last year before \(t\), we specify eps = 1 and direction = "back" in the call to slope(). This calculates the term \(\{\eta(t) - \eta(t - \varepsilon)\} / \varepsilon\) for \(\varepsilon\) set equal to eps = 1:

jFit2 <- jm(CoxFit, gm, time_var = "year",
            functional_forms = ~ value(log(serBilir)) + 
              slope(log(serBilir), eps = 1, direction = "back"))

We compare the two fits

summary(jFit1)$Survival
#>                           Mean     StDev       2.5%     97.5%         P
#> sexfemale            -0.175060 0.3035789 -0.7679787 0.4278808 0.5633333
#> value(log(serBilir))  1.200291 0.1337280  0.9413599 1.4690155 0.0000000
#> slope(log(serBilir))  2.650226 0.7417528  1.1946394 4.2852976 0.0000000
#>                          Rhat
#> sexfemale            1.014335
#> value(log(serBilir)) 1.008638
#> slope(log(serBilir)) 1.017037

summary(jFit2)$Survival
#>                                                         Mean     StDev
#> sexfemale                                         -0.1598636 0.3003916
#> value(log(serBilir))                               1.1889780 0.1360777
#> slope(log(serBilir), eps = 1, direction = "back")  2.5348042 0.7263611
#>                                                         2.5%     97.5%
#> sexfemale                                         -0.7288346 0.4359363
#> value(log(serBilir))                               0.9208692 1.4540478
#> slope(log(serBilir), eps = 1, direction = "back")  1.1490629 4.1628415
#>                                                           P     Rhat
#> sexfemale                                         0.5797778 1.003257
#> value(log(serBilir))                              0.0000000 1.028793
#> slope(log(serBilir), eps = 1, direction = "back") 0.0000000 1.024939