Skip to content

generable/r-pharma-bmstate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

r-pharma-bmstate

Multistate modeling tutorial in R Pharma by Generable.

Overview

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.

Requirements

Quick Start

Install Prerequisites

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.

Package Management with renv

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.

Render Tutorials

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

Tutorial Structure

Introduction - intro/

  • intro-slides.qmd: Welcome slides and warm-up poll

Personalized Dosing

  • BayesPharma 2025: Presentation on personalized dosing decisions using multistate modeling

Disease Progression Analysis

  • vignette: Tutorial on analyzing Cardiac Allograft Vasculopathy (CAV) data

Oncology Data Analysis - squire/

  • slides.qmd: Main tutorial slides for analyzing SQUIRE clinical trial data
  • analysis-fit0.qmd: Rendered tutorial for initial multistate model fit
  • analysis-fit0.R: R script for initial multistate model fit
  • analysis-fit1-add-no-progression.R: Adding no-progression state
  • analysis-fit2-informative-censoring.R: Modeling informative censoring

Data

Data files are located in squire/data/. See squire/data/README.md for details about the SQUIRE clinical trial data.

License

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.

About

Multistate modeling tutorial in R Pharma by Generable

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages