Description Usage Arguments Value Examples
View source: R/statepathways.R
Produces an interactive HTML widget that displays a Sankey diagram showing a predicted patient pathway through the multi-state model.
1 2 3 4 5 6 7 8 | plot_predicted_pathway(
models,
trans_mat,
newdata,
times,
starting_state = 1,
tcovs = NULL
)
|
models |
List of |
trans_mat |
Transition matrix, such as that used in |
newdata |
A data frame containing the attributes of the person to display the predicted state flow for. As the diagram can only be displayed for a single individual it will ignore any rows after the first. |
times |
The time-points at which to estimate transition probabilities. |
starting_state |
Starting state. Either number or character name in |
tcovs |
As in |
The HTML widget.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | library(multistateutils)
library(mstate)
library(flexsurv)
# Convert data to long
data(ebmt3)
tmat <- trans.illdeath()
long <- msprep(time=c(NA, 'prtime', 'rfstime'),
status=c(NA, 'prstat', 'rfsstat'),
data=ebmt3,
trans=tmat,
keep=c('age', 'dissub'))
# Fit parametric models
models <- lapply(1:3, function(i) {
flexsurvreg(Surv(time, status) ~ age + dissub, data=long, dist='weibull')
})
# New individual to estimate transition probabilities for
newdata <- data.frame(age="20-40", dissub="AML")
# Plot pathway diagram at 2-yearly intervals up to 10-years
time_points <- seq(0, 10, by=2) * 365.25
plot_predicted_pathway(models, tmat, newdata, time_points, 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.