We are interested in replicating several duration studies in the literature using ensemble learning methods. After some experimentation, we opted for random survival forests (Ishwaran et al. 2008) for their simplicity and performance. However, the package randomForestSRC in R only allows for time-invariant covariates. As one might guess, many interesting theoretical problems usually involve parameters that take on different values over time. Does anyone know how to implement TVCs in R using machine learning? We would prefer sticking to random forests, but naturally would switch if there is a better alternative.


1 Answer 1


The most widely used approach for survival analysis of time-varying covariates (TVCs) are Cox models. There you need to create a dataset with TVCs which is described in this vignette

fit.cox <- coxph(Surv(time1, time2, event) ~ x), data = data)

However there is also the possibility to include TVCs in random survival forests. This paper by Wongvibulsin, Wu, and Zeger (2019) extends the randomForestSRC package to handle TVC, but you may need to contact the authors for any relevant code.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.