# Bayesian Survival Analysis - COX PHD Time Varying Covariates Implementation

Suppose you are interested in the Survival modelling technique Cox Proportional Hazard, where we model the hazard as:

$$\lambda(t \vert x) = \lambda_0(t) exp (\beta x)$$

An extension of this model is time-varying covariates i.e.

$$\lambda(t \vert x(t)) = \lambda_0(t) exp (\beta x(t))$$

Another extension is time-dependent effects i.e.:

$$\lambda(t \vert x) = \lambda_0(t) exp (\beta(t)x)$$

I am interested in time-varying covariates and have strong prior beliefs over the coefficients of the covariates (in the partial hazard) as well as the baseline. I have seen examples of Bayesian survival modelling (with Cox PHD) where you have time-dependent effects (i.e. a sequence of regression coefficients), see this example using PyMC3 and Python:

However, in the situation where you have time varying covariates, I am yet to find an example or implementation of this in python (or R for that matter). My question is:

1. Is there a reason why you do not see implementations of Bayesian time-varying covariates COX PHD?
2. If no to the above, does anyone have a good example of an implementation?

Many thanks

• How many distinct event times are there in your data? If you happen to have a discrete time problem this is easier to handle. – Frank Harrell Feb 21 at 12:53

## 1 Answer

If you get the development version of rstanarm package, it has function called stan_surv that allows for time-varying coefficients in Bayesian survival models. Importantly, you can even model flexible baseline hazards with M and B splines. You can find out more here:

https://arxiv.org/pdf/2002.09633.pdf

https://github.com/stan-dev/rstanarm

• Thanks Brant. Do you know if this covers time varying covariates as well as time varying coefficients? – Jonny Kisch Feb 22 at 10:18
• Seems to does...do you also happen to know if the python implementation Survivalstan has the same features developed as the R implementation with stan_surv? – Jonny Kisch Feb 22 at 10:44
• Sorry I don't use Python and have no idea. – Brant Inman Feb 22 at 19:44