The standard joint model was described and illustrated with `megenreg`

here. In this example we consider time-dependent effects in the survival submodel. Once again we have,

$$h(t) = h_{0}(t) \exp(X_{1ij}\mathbf{\beta_{1}} + \alpha m_{i}(t))$$

and

$$y_{}(t) = m_{i}(t) + \epsilon_{ij}$$

where

$$m_{i}(t) = X_{2ij}(t)\mathbf{\beta}_{2} + Z_{ij}(t)b_{i}$$

and

$$b_{i} \sim N(0,\Sigma)$$

Given the survival submodel is a proportional hazards model, we are making the assumption that both our hazard ratios $\exp (\beta_{1})$ for the covariates $X_{1ij}$, and the hazard ratio for the effect of our biomarker, $\exp(\alpha)$, are constant across follow-up time. We can relax these assumptions to allow for non-proportional hazards i.e. by modelling time-dependent effects. First we consider the following model,

$$h(t) = h_{0}(t) \exp(X_{1ij}\beta_{1}(t) + \alpha m_{i}(t))$$

where if we assume $X_{1ij}$ is a binary treatment variable, we can allow its associated hazard ratio $\beta_{1}(t)$ to be time-dependent, by making it a function of $\log (t)$

$$h(t) = h_{0}(t) \exp(X_{1ij} \beta_{1} + X_{1ij} \times \beta_{2} \times \log (t) + \alpha m_{i}(t))$$

We can fit this model with `megenreg`

as follows

```
megenreg (stime trt trt#fp(0)@beta2 EV[logb]@alpha, family(weibull, failure(event)) timevar(stime))
(logb fp(1)@l1 fp(1)#M2[id] M1[id], family(gaussian) timevar(time))
```

We can also relax the proportional hazards assumption on our association parameter, as follows,

$$h(t) = h_{0}(t) \exp(X_{1ij}\mathbf{\beta_{1}} + \alpha_{1} m_{i}(t) + \alpha_{2} \times \log (t) \times m_{i}(t) )$$

which can be fitted using,

```
megenreg (stime trt EV[logb]@alpha1 EV[logb]#fp(0)@alpha2,
family(weibull, failure(event)) timevar(stime))
(logb fp(1)@l1 fp(1)#M2[id] M1[id], family(gaussian) timevar(time))
```

For completeness we can model non-proportional hazards in both our treatment effect and our association parameter as follows,

```
megenreg (stime trt trt#fp(0)@beta2 EV[logb]@alpha1 EV[logb]#fp(0)@alpha2,
family(weibull, failure(event)) timevar(stime))
(logb fp(1)@l1 fp(1)#M2[id] M1[id], family(gaussian) timevar(time))
```

In any of the models above, there is no restriction on what functional form we use to model each of the time-dependent effects. If a more complex form is desired, then we can use the `fp()`

or `rcs()`

syntax to get more flexible time functions. For example using fractional polynomials,

```
megenreg (stime trt EV[logb]@alpha1 EV[logb]#fp(1 2)@alpha2,
family(weibull, failure(event)))
(logb fp(1)@l1 fp(1)#M2[id] M1[id], family(gaussian) timevar(time))
```

or restricted cubic splines,

```
megenreg (stime trt EV[logb]@alpha1 EV[logb]#rcs(df(3) log)@alpha2,
family(weibull, failure(event)))
(logb fp(1)@l1 fp(1)#M2[id] M1[id], family(gaussian) timevar(time))
```

I’ve also only shown a time-dependent effect under the current value parameterisation. Any of the other structures shown here can also be made time-dependent in a similar way.