The do file with all the code from this tutorial is available to download here

An area of intense research in recent years is in the field of joint frailty survival models, for the analysis of joint recurrent event and terminal event data. Here I’ll describe and implement the two most popular approaches, originally proposed by Liu et al. (2004) and Mazroui et al. (2012). We have a survival model for the recurrent event process, and a survival model for the terminal event process, linked through shared random effects.

I’ll illustrate these models using the `readmission`

dataset that comes with the extensive `frailtypack`

in `R`

(Król et al. (2017)), developed by Virginie Rondeau and her group.
The dataset has information on rehospitalisation times after surgery in patients diagnosed with colorectal cancer.
Covariates of interest include gender, Dukes’ tumour stage and comorbidity Charlson index. I’ll load the dataset
and generate binary indicator variables for use later.

```
. use "https://www.mjcrowther.co.uk/data/jointfrailty_example",clear
. tab sex, gen(gender)
sex | Freq. Percent Cum.
------------+-----------------------------------
Female | 312 36.24 36.24
Male | 549 63.76 100.00
------------+-----------------------------------
Total | 861 100.00
. tab dukes, gen(dk)
dukes | Freq. Percent Cum.
------------+-----------------------------------
A-B | 324 37.63 37.63
C | 331 38.44 76.07
D | 206 23.93 100.00
------------+-----------------------------------
Total | 861 100.00
. tab charlson, gen(ch)
charlson | Freq. Percent Cum.
------------+-----------------------------------
0 | 577 67.02 67.02
1-2 | 46 5.34 72.36
3 | 238 27.64 100.00
------------+-----------------------------------
Total | 861 100.00
```

The time of rehospitalisation is stored in `time`

, with corresponding event indicator `event`

. This is in clock-reset
formulation, i.e. each time a patient has a cancer recurrence the clock is reset to zero, so it’s a semi-Markov model.
Our overall survival time is stored in `stime`

, with corresponding event indicator stored in `death`

.

In the first specification, we have one random effect which accounts for the correlation between recurrent events, and which is then included in the linear predictor for the terminal event model, with an accompanying estimated coefficient, which estimates the strength of the relationship between the two processes. So for example,

$$ h_{ij}(t) = h_{0}(t) \exp (X_{1ij} \beta_{1} + b_{i}) $$ and $$ \lambda_{i}(u) = \lambda_{0}(u) \exp (X_{1i} \beta_{2} + \alpha b_{i}) $$

where $h_{ij}(t)$ is the hazard function for the $j$th event of the $i$th patient, $\lambda_{i}(u)$ is the hazard function for the terminal event, and $b_{i} \sim N(0,\sigma^2)$.

We can fit such a model with `merlin`

, adjusting for all available covariates in each outcome model,

```
. merlin (time gender1 dk2 dk3 ch2 ch3 M1[id]@1 , family(rp, df(3) failure(event))) ///
> (stime gender1 dk2 dk3 ch2 ch3 M1[id] , family(rp, df(1) failure(death)))
variables created: _rcs1_1 to _rcs1_3
variables created: _rcs2_1 to _rcs2_1
Fitting fixed effects model:
Fitting full model:
Iteration 0: log likelihood = -4188.9255
Iteration 1: log likelihood = -4175.0335 (not concave)
Iteration 2: log likelihood = -4147.9322
Iteration 3: log likelihood = -4143.6851
Iteration 4: log likelihood = -4143.6239
Iteration 5: log likelihood = -4143.6239
Mixed effects regression model Number of obs = 861
Log likelihood = -4143.6239
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
time: |
gender1 | -.4603476 .1407838 -3.27 0.001 -.7362787 -.1844164
dk2 | .4080402 .157101 2.60 0.009 .100128 .7159524
dk3 | 1.395736 .2068641 6.75 0.000 .99029 1.801183
ch2 | .3244106 .2581746 1.26 0.209 -.1816023 .8304234
ch3 | .3478033 .1353953 2.57 0.010 .0824335 .6131731
M1[id] | 1 . . . . .
_cons | -2.126217 .1482472 -14.34 0.000 -2.416776 -1.835657
-------------+----------------------------------------------------------------
stime: |
gender1 | -.353336 .225481 -1.57 0.117 -.7952706 .0885986
dk2 | .9249671 .3356407 2.76 0.006 .2671234 1.582811
dk3 | 2.960989 .4042644 7.32 0.000 2.168645 3.753333
ch2 | .7341092 .6293611 1.17 0.243 -.4994159 1.967634
ch3 | 1.058568 .2494584 4.24 0.000 .5696388 1.547498
M1[id] | .9107476 .2383293 3.82 0.000 .4436307 1.377864
_cons | -3.24061 .3218223 -10.07 0.000 -3.87137 -2.60985
-------------+----------------------------------------------------------------
id: |
sd(M1) | .8002133 .082537 .653747 .9794942
------------------------------------------------------------------------------
Warning: Baseline spline coefficients not shown - use ml display
```

We now have two model specifications, each of which can be completely different. I’ve used Royston-Parmar survival models. We define a random effect with the same name in each linear predictor, which means only one random effect has been defined, but it is included in both outcome models. In the first model, I’ve simply constrained the coefficient of the random effect to be 1. This provides a highly convenient way of linking random effects between outcome models. Our results show a highly positive estimate of associtaion of 0.910 (95% CI: 0.444, 1.378) showing substantial association between the two event processes, i.e. a higher rate of rehospitalisation also increases the mortality rate.

The second approach consists of two random effects included in the recurrent event model, one of which is also included in the linear predictor of the terminal event model, as follows,

$$ h_{ij}(t) = h_{0}(t) \exp (X_{1ij} \beta_{1} + b_{1i} + b_{2i}) $$ and $$ \lambda_{i}(u) = \lambda_{0}(u) \exp (X_{1i} \beta_{2} + b_{2i}) $$

where $b_{1i} \sim N(0,\sigma_{1}^2)$ and $b_{2i} \sim N(0,\sigma_{2}^2)$. Our $\sigma_{2}$ parameter then
indicates the association between the two processes. We can fit this model with `merlin`

, this time illustrating
how to use different distributions for the recurrent event and terminal event processes,

```
. merlin (time gender1 dk2 dk3 ch2 ch3 M1[id]@1 M2[id]@1 , family(rp, df(3) failure(event))) ///
> (stime gender1 dk2 dk3 ch2 ch3 M2[id]@1 , family(rp, df(1) failure(death)))
variables created: _rcs1_1 to _rcs1_3
variables created: _rcs2_1 to _rcs2_1
Fitting fixed effects model:
Fitting full model:
Iteration 0: log likelihood = -4211.9343
Iteration 1: log likelihood = -4149.7324
Iteration 2: log likelihood = -4142.7638
Iteration 3: log likelihood = -4142.5391
Iteration 4: log likelihood = -4142.5347
Iteration 5: log likelihood = -4142.5346
Mixed effects regression model Number of obs = 861
Log likelihood = -4142.5346
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
time: |
gender1 | -.4617124 .1439661 -3.21 0.001 -.7438807 -.1795441
dk2 | .4038231 .1597782 2.53 0.011 .0906636 .7169827
dk3 | 1.37028 .2084706 6.57 0.000 .9616853 1.778875
ch2 | .3259098 .2628613 1.24 0.215 -.1892888 .8411085
ch3 | .3437377 .1366298 2.52 0.012 .0759482 .6115271
M1[id] | 1 . . . . .
M2[id] | 1 . . . . .
_cons | -2.153942 .1511437 -14.25 0.000 -2.450178 -1.857705
-------------+----------------------------------------------------------------
stime: |
gender1 | -.3586175 .2282707 -1.57 0.116 -.8060198 .0887849
dk2 | .9218049 .3362931 2.74 0.006 .2626827 1.580927
dk3 | 2.992593 .3711618 8.06 0.000 2.265129 3.720057
ch2 | .7382444 .6340333 1.16 0.244 -.504438 1.980927
ch3 | 1.130695 .2543351 4.45 0.000 .6322078 1.629183
M2[id] | 1 . . . . .
_cons | -3.267829 .2988515 -10.93 0.000 -3.853567 -2.682091
-------------+----------------------------------------------------------------
id: |
sd(M1) | .3860645 .1480007 .1821149 .8184162
sd(M2) | .7341318 .097828 .5653868 .9532403
------------------------------------------------------------------------------
Warning: Baseline spline coefficients not shown - use ml display
```

This defines two random effects at the `id`

level, which by default have an independent covariance structure.
Our estimate of $\sigma_{1}$ is 0.386 (95% CI: 0.182, 0.818),
and similarly we obtain an estimate for $\sigma_{2}$ of 0.734 (95% CI: 0.565, 0.953).

From both a theoretical and interpretation perspective, I prefer the first of these two joint frailty models. If there was no association, then $\sigma_{1} = 0$, which is at the boundary of its parameter space, and hence unlikely to converge, compared to $\alpha = 0$ from model 1.

Extensions including higher levels, time-dependent effects, non-linear covariate effects and the relative survival extension can be included very simply.

This example used `merlin`

version 1.15.1.