Bayesian Survival and Multistate Models using R and Stan
Time-to-event analysis with patient preferences
Overview
Advanced Bayesian Survival Analysis
Bayesian inference and Stan offer many advantages for time-to-event data: incorporating prior knowledge, propagating uncertainty, and integrating patient utility functions for optimal decision-making. Learn multistate models for competing events in cardiovascular and oncology trials.
What Youβll Learn
- π Bayesian workflow - Typical analysis steps
- β±οΈ Survival models - Single and competing events
- π Multistate models - Bleeding, stroke, death pathways
- π― Patient preferences - Utility function integration
- π Decision analysis - Optimal treatment selection
Prerequisites
Required Knowledge:
- Intermediate R programming
- Basic survival analysis concepts
- Some Bayesian exposure helpful
Recommended:
- Stan familiarity (not required)
- Clinical trial experience
Key Tools
Stan
{bmstate}
{rstan}
{cmdstanr}
Workshop Materials
GitHub Package: github.com/generable/bmstate
Why Bayesian for Survival Analysis?
Advantages
1. Prior Information Integration
- Use historical trial data
- Expert knowledge incorporation
- Borrowing strength across studies
2. Uncertainty Quantification
- Full posterior distributions
- Credible intervals
- Probability statements
3. Patient Preferences
- Utility function integration
- Trade-offs between outcomes
- Personalized decision-making
4. Complex Models
- Multistate transitions
- Competing risks
- Time-varying effects
Bayesian Workflow
Step 1: Prior Specification
parameters {
real log_baseline_hazard;
real treatment_effect;
}
model {
// Priors
log_baseline_hazard ~ normal(-2, 1);
treatment_effect ~ normal(0, 0.5);
}Step 2: Prior Predictive Checks
Simulate data from priors to verify reasonableness.
Step 3: Fit Model
library(bmstate)
fit <- fit_survival_model(
formula = Surv(time, status) ~ treatment,
data = clinical_data,
prior = prior_spec
)Step 4: Posterior Diagnostics
- Check convergence (R-hat)
- Effective sample size
- Trace plots
- Posterior predictive checks
Step 5: Inference
Extract posterior summaries and make decisions.
Single-Event Survival Models
Exponential Model
Constant hazard over time.
Weibull Model
Flexible hazard shape (increasing/decreasing).
Piecewise Exponential
Different hazards in time intervals.
Cox-Like Models
Semi-parametric baseline with covariates.
Multistate Models
Example: Cardiovascular Trial
States:
- Healthy
- Bleeding event
- Stroke event
- Death
Transitions:
- Healthy β Bleeding
- Healthy β Stroke
- Healthy β Death
- Bleeding β Death
- Stroke β Death
Oncology Trial
States:
- Stable disease
- Progressive disease
- Death
Allows:
- Different treatment effects on each transition
- Competing risks modeling
- Illness-death models
Patient Utility Functions
Incorporating Preferences
Patients may value outcomes differently:
- Prefer minor bleeding over stroke
- Trade survival time for quality
- Different risk tolerances
Example Utility
# Patient preferences
utility <- function(state, time) {
switch(state,
"healthy" = 1.0,
"bleeding" = 0.8, # 20% quality loss
"stroke" = 0.3, # 70% quality loss
"death" = 0.0
)
}Decision Analysis
Use utilities to:
- Compare treatment strategies
- Calculate quality-adjusted survival
- Optimize individual decisions
Workshop Exercises
Exercise 1: Single-Event Model
Fit Weibull survival model to trial data.
Exercise 2: Multistate Model
Cardiovascular trial with bleeding/stroke competing events.
Exercise 3: Utility Integration
Incorporate patient preferences into decision analysis.
Practical Example
library(bmstate)
# Fit multistate model
fit <- fit_multistate(
formula = list(
bleeding ~ treatment + age,
stroke ~ treatment + age + prior_stroke,
death ~ treatment + age
),
data = cardio_data,
transitions = transition_matrix
)
# Extract hazard ratios
hr_bleeding <- exp(posterior_summary(fit, "treatment_bleeding"))
hr_stroke <- exp(posterior_summary(fit, "treatment_stroke"))
# Decision analysis with utilities
qaly <- calculate_qaly(
fit = fit,
utilities = patient_utilities,
horizon = 5 # years
)Advantages in Pharma
Regulatory
- Explicit uncertainty quantification
- Transparent assumptions (priors)
- Flexible for complex designs
Scientific
- Accumulate knowledge across trials
- Handle small samples better
- Natural borrowing of information
Patient-Centered
- Individual risk-benefit
- Preference integration
- Personalized medicine
Learning Outcomes
β
Understand Bayesian workflow for survival data
β
Fit single-event survival models in Stan
β
Build multistate models for competing risks
β
Integrate patient utility functions
β
Perform Bayesian decision analysis
β
Interpret and communicate Bayesian results
Advanced Topics (Time Permitting)
- Cure models
- Recurrent events
- Joint models (longitudinal + survival)
- Hierarchical models
Resources
- {bmstate} documentation
- Bayesian Survival Analysis (Ibrahim et al.)
- Stan Userβs Guide - Survival chapter
- Statistical Rethinking (McElreath)
Similar Workshops
- Debugging Stan - Stan troubleshooting skills
- rpact Trial Design - Frequentist designs
Next Steps
- Prerequisites: Debugging Stan workshop highly recommended
- Career value: Bayesian expertise opens doors
Last updated: November 2025 | R/Pharma 2025 Conference