I’ve just released an R package for estimating transition probabilities from multi-state models onto Github, found at https://github.com/stulacy/RDES.
It’s not a package with a large potential audience, so I don’t intend to release it onto CRAN, rather it has a highly specific role that I developed for my own use and thought it could prove useful for someone else.
Essentially, it extends the simulation functionality offered by the fantastic flexsurv
package for obtaining predicted outcomes from multi-state models.
In particular, it currently estimates transition probabilities with the following additional features over flexsurv
. See the README for more details and examples.
- Quicker to run
- Can estimate multiple end times at once
- The start time can be changed
- Can estimate probabilities for multiple individuals at once
- Allows the use of time-dependent covariates
- Can handle a mixture of distributions
I had happily been using flexsurv
for estimating transition probabilities until I found a few issues with the main function pmatrix.simfs
that I needed for my research, for example time-dependent covariates not working and it was quite slow when estimating probabilities at multiple time-points.
I had previously written a discrete event simulation engine in C++ for a separate health economic evaluation project, which simulated the flow of diagnosed cases of a particular disease through the treatment pathway in order to obtain estimates of costs to the healthcare provider.
I realised that this simulation engine could quite simply be adapted to the case of estimating transition probabilities for specific individuals by running a large number (10,000) of individuals with identical covariate patterns through the system in the same way as flexsurv
without too much additional work.
Plus, since the engine was written in C++ it would be fast.
Furthermore, by having full control of the implementation I could add the features most important to me, such as being able to run multiple individuals through the simulation and obtain transition probability estimates at several time-points in one function call.
I implemented this interface to the simulation engine and have now released it since there may be others who are interested in these features. At some point I’d like to extend it with additional functionality, such as:
- Length of stay estimates, as in
flexsurv::totlos.simfs
- A clean interface to the cohort simulation that others can use
- Clean up the web-app front-end to the cohort simulation that I’ve written (source code here) and provide an interface to individual level simulations
I may also turn it into a generic package containing helper functions for multi-state modelling in R, in particular for the use of such models for applied situations, since others (mstate
, msm
, flexsurv
) have already done such a good job with the actual modelling side of things.
One aspect of multi-state modelling in particular that I’m interested in is in ways of visualising the output of these potentially complex models, having previously used a web-app to intuitively build the transition matrix with visual feedback.
I’ve been turning to Sankey diagrams to express these transition probabilities, such as in the example treatment flow diagram below, and I think a suite of visualisation tools such as this could be beneficial to the biostatistics/epidemiology community.