Multistate modeling tutorial in R Pharma by Generable.
This repository contains tutorial materials for Bayesian multistate modeling using the bmstate package. The tutorial covered several topics:
- Introduction & warmup exercises (
intro/) - Personalized dosing: the motivation behind bmstate (see slides from BayesPharma 2025)
- Disease progression analysis (based on the bmstate vignette)
- Oncology data analysis (
squire/)
Access the posit cloud template.
To install prerequisites, run the following in R:
install.packages('remotes')
# set up cmdstan
remotes::install_github('stan-dev/cmdstanr')
cmdstanr::install_cmdstan()
# set up bmstate
remotes::install_github('generable/bmstate', build_vignettes = TRUE)If you are on the posit cloud workstation, restart your session after installing cmdstan.
This repository includes renv for reproducible package management. When you open the project in R, renv will automatically activate and prompt you to restore packages from the lockfile.
To restore packages:
renv::restore()Note: renv is included for convenience but is optional. To disable renv, simply delete the .Rprofile file in the project root. The tutorials will work with or without renv.
The CAV tutorial is available as a vignette from the bmstate package. View it by running:
vignette("analysis", package="bmstate")The other tutorials are written in Quarto. To render them:
# Render a specific tutorial
quarto::quarto_render("intro/intro-slides.qmd")
quarto::quarto_render("squire/slides.qmd")
quarto::quarto_render("squire/analysis-fit0.qmd")Or use the Quarto CLI:
quarto render intro/intro-slides.qmd
quarto render squire/slides.qmd
quarto render squire/analysis-fit0.qmdintro-slides.qmd: Welcome slides and warm-up poll
- BayesPharma 2025: Presentation on personalized dosing decisions using multistate modeling
- vignette: Tutorial on analyzing Cardiac Allograft Vasculopathy (CAV) data
slides.qmd: Main tutorial slides for analyzing SQUIRE clinical trial dataanalysis-fit0.qmd: Rendered tutorial for initial multistate model fitanalysis-fit0.R: R script for initial multistate model fitanalysis-fit1-add-no-progression.R: Adding no-progression stateanalysis-fit2-informative-censoring.R: Modeling informative censoring
Data files are located in squire/data/. See squire/data/README.md for details about the SQUIRE clinical trial data.
Code: This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
Text and Documentation: All text content, tutorials, and documentation in this repository are licensed under Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0).
This means you are free to:
- Share — copy and redistribute the material in any medium or format for any purpose, even commercially.
Under the following terms:
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
- NoDerivatives — If you remix, transform, or build upon the material, you may not distribute the modified material.