plot_predicted_pathway: Displays the predicted flow for a given individual through...

Description Usage Arguments Value Examples

View source: R/statepathways.R

Description

Produces an interactive HTML widget that displays a Sankey diagram showing a predicted patient pathway through the multi-state model.

Usage

1
2
3
4
5
6
7
8
plot_predicted_pathway(
  models,
  trans_mat,
  newdata,
  times,
  starting_state = 1,
  tcovs = NULL
)

Arguments

models

List of flexsurvreg objects.

trans_mat

Transition matrix, such as that used in mstate.

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 trans_mat.

tcovs

As in flexsurv::pmatrix.simfs, this is the names of covariates that need to be incremented by the simulation clock at each transition, such as age when modelled as age at state entry.

Value

The HTML widget.

Examples

 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)

multistateutils documentation built on Dec. 16, 2019, 1:19 a.m.