Stacked Probability Plots for Multi-State Survival Models

Facilitate the creation of stacked probability plots for multi-state survival models with 'ggplot2'. Each function from the package creates a proper 'ggplot2' object that can be modified with any function from the 'ggplot2' or any of its extensions.


ggstackedsurv

The ggstackedsurv package makes the generation of stacked survival probability plots with ggplot2 easier. It draws heavily from the syntax and the style of ggsurvfit.

What are “stacked probability plots”?

Stacked probability plots are an efficient way to visualize the probabilities of being in each state of a multi-state model over time. Since all patients have to be in one of the states, the probabilities of being in each state at a given time always sum to 1, making for a nice and compact visualization.

A good example can be found in this 2020 paper about extra-corporeal membrane oxygenation (ECMO) in COVID-19 patients (Schmidt et al. 2020)

Why ggstackedsurv ?

Originally, the plan was to add these functions as a functionality to the ggsurvfit package. However, stacked probability plots are uncommon and out of the scope of ggsurvfit, so making it a separate package seemed the right choice.

Plotting stacked probabilities is already possible with the plot.trans() function from the mstate package. However, two crucial (imho) functionalities were lacking:

  • rendering the plot with ggplot2, which allows for limitless and easy customization, and easy exporting,
  • working with models from the survival package, since it is the one mostly used for survival models (even mutlistate ones).

Installation

You can install ggstackedsurv from CRAN with:

install.packages("ggstackedsurv")

You can install the development version of ggstackedsurv from GitHub with:

# install.packages("pak")
pak::pak("ABohynDOE/ggstackedsurv")

Examples

The package is quite simple and only produces one type of figure, as shown in the code below

library(ggstackedsurv)
library(survival)

# Create a multi-state model using the ecmo example data
fit <- survfit(Surv(time, status) ~ 1, data = ecmo)

# Plot the survival probabilities of each state over time
ggstackedsurv(fit, base_state = "on ECMO") +
  add_risktable()

Schmidt, Matthieu, David Hajage, Guillaume Lebreton, et al. 2020. “Extracorporeal Membrane Oxygenation for Severe Acute Respiratory Distress Syndrome Associated with COVID-19: A Retrospective Cohort Study.” The Lancet Respiratory Medicine 8 (11): 1121–31. https://doi.org/10.1016/S2213-2600(20)30328-3.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ggstackedsurv")

0.1.0 by Alexandre Bohyn, 2 days ago


https://github.com/ABohynDOE/ggstackedsurv


Report a bug at https://github.com/ABohynDOE/ggstackedsurv/issues


Browse source code at https://github.com/cran/ggstackedsurv


Authors: Alexandre Bohyn [aut, cre, cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, ggplot2, glue, grid, patchwork

Suggests survival, testthat, withr


See at CRAN