Bayesian workflow for disease transmission modeling in Stan - PubMed (original) (raw)
. 2021 Nov 30;40(27):6209-6234.
doi: 10.1002/sim.9164. Epub 2021 Sep 8.
Affiliations
- PMID: 34494686
- PMCID: PMC8661657
- DOI: 10.1002/sim.9164
Bayesian workflow for disease transmission modeling in Stan
Léo Grinsztajn et al. Stat Med. 2021.
Abstract
This tutorial shows how to build, fit, and criticize disease transmission models in Stan, and should be useful to researchers interested in modeling the severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) pandemic and other infectious diseases in a Bayesian framework. Bayesian modeling provides a principled way to quantify uncertainty and incorporate both data and prior knowledge into the model estimates. Stan is an expressive probabilistic programming language that abstracts the inference and allows users to focus on the modeling. As a result, Stan code is readable and easily extensible, which makes the modeler's work more transparent. Furthermore, Stan's main inference engine, Hamiltonian Monte Carlo sampling, is amiable to diagnostics, which means the user can verify whether the obtained inference is reliable. In this tutorial, we demonstrate how to formulate, fit, and diagnose a compartmental transmission model in Stan, first with a simple susceptible-infected-recovered model, then with a more elaborate transmission model used during the SARS-CoV-2 pandemic. We also cover advanced topics which can further help practitioners fit sophisticated models; notably, how to use simulations to probe the model and priors, and computational techniques to scale-up models based on ordinary differential equations.
Keywords: Bayesian workflow; compartmental models; epidemiology; infectious diseases.
© 2021 John Wiley & Sons Ltd.
Conflict of interest statement
The authors declare no conflict of interests.
Figures
FIGURE 1
Coding blocks in a
Stan
file. The operations in certain blocks are performed multiple times and in some cases differentiated; as a result, the computational cost of fitting the model is dominated by the transformed parameters and model blocks. Not shown is the
functions
block, which defines functions that can be called in any of the operative blocks
FIGURE 2
Model development as an iterative process
FIGURE 3
Number of students in bed each day during an influenza A (H1N1) outbreak at a British boarding school between January 22 and February 4, 1978
FIGURE 4
Diagram of the classic susceptible‐infectious‐recovered compartmental model
FIGURE 5
Prior predictive checks for (A) the recovery time (1/γ), (B) the basic reproduction number ℛ0 (β/γ), (C) the dispersion parameter (ϕ), (D) a set of 1000 epidemic trajectories (each line is a unique simulated trajectory), and (E) the range in the numbers of students in bed each day (the line is the median and the light teal area is the 95% central range). All these quantities are sampled from the prior distributions of the parameters. The dashed red lines correspond to weak bounds from our domain knowledge where available: The recovery time is expected to last between 0.5 and 30 days, ℛ0 cannot be lower than 1 or higher than 10. The plain horizontal red line shows the population size (763) [Colour figure can be viewed at
wileyonlinelibrary.com
]
FIGURE 6
A, Trace plot showing the value of each chain at each iteration (excluding warm‐up) and B, marginal posterior densities for the transmission rate (
beta
or β), the recovery rate (
gamma
or γ) and the inverse dispersion parameter (
phi_inv
or 1/ϕ), separately for each of the four Markov chains [Colour figure can be viewed at
wileyonlinelibrary.com
]
FIGURE 7
Marginal posterior densities for the transmission rate (
beta
or β), the recovery rate (
gamma
or γ) and the inverse dispersion parameter (
phi_inv
or 1/ϕ) obtained when fitting the model to simulated data. The red dashed lines show the fixed parameter values used for simulating the data [Colour figure can be viewed at
wileyonlinelibrary.com
]
FIGURE 8
A, Posterior predictive check of the number of students in bed each day during an influenza A (H1N1) outbreak at a British boarding school. The line shows the median and the orange area the 90% prediction interval. B, Prior and posterior predictive checks of the basic reproduction number ℛ0 and of the recovery time (both truncated at 8). The dot shows the median posterior and the line shows the 95% credible interval [Colour figure can be viewed at
wileyonlinelibrary.com
]
FIGURE 9
Daily number of reported cases of severe acute respiratory syndrome coronavirus 2 infection in Switzerland between February and June, 2020
FIGURE 10
A, Posterior distributions of the model parameters (the transmission rate β, the recovery rate γ and the inverse dispersion parameter 1/ϕ) and B, chain‐by‐chain posterior predictive check of the number of reported cases for the simple SIR model (model iteration #1) applied to data on the SARS‐CoV‐2 epidemic in Switzerland (white circles). SARS‐CoV‐2, severe acute respiratory syndrome coronavirus 2; SIR, susceptible‐infected‐recovered [Colour figure can be viewed at
wileyonlinelibrary.com
]
FIGURE 11
Diagram of a SEIR model
FIGURE 12
A, Trace plot for two of the model parameters (the incubation rate a and the reporting rate pr—the other parameters are not shown) and B, posterior predictive check of the number of reported cases for the SEIR model with underreporting (model iteration #3) applied to data on the SARS‐CoV‐2 epidemic in Switzerland (white circles). SARS‐CoV‐2, severe acute respiratory syndrome coronavirus 2 [Colour figure can be viewed at
wileyonlinelibrary.com
]
FIGURE 13
Pairs plot of all model parameters for the model incorporating control measures (model iteration #5) [Colour figure can be viewed at
wileyonlinelibrary.com
]
FIGURE 14
(A) Posterior predictive check of the number of reported cases and (B) of the cumulative incidence for the SEIR model including the effect of control measures and fitted to both reported cases and seroprevalence data (model iteration #7; white circles show data on reported cases in panel A and seroprevalence data in panel B). (C) Posterior distribution of the forcing function f that models the reduction in transmission after the introduction of lockdown measures. (D) Prior and posterior distributions of the parameters of model iteration #7 [Colour figure can be viewed at
wileyonlinelibrary.com
]
Similar articles
- Flexible and efficient Bayesian pharmacometrics modeling using Stan and Torsten, Part I.
Margossian CC, Zhang Y, Gillespie WR. Margossian CC, et al. CPT Pharmacometrics Syst Pharmacol. 2022 Sep;11(9):1151-1169. doi: 10.1002/psp4.12812. Epub 2022 Jun 23. CPT Pharmacometrics Syst Pharmacol. 2022. PMID: 35570331 Free PMC article. - A comparison of computational algorithms for the Bayesian analysis of clinical trials.
Chen Z, Berger JS, Castellucci LA, Farkouh M, Goligher EC, Hade EM, Hunt BJ, Kornblith LZ, Lawler PR, Leifer ES, Lorenzi E, Neal MD, Zarychanski R, Heath A. Chen Z, et al. Clin Trials. 2024 Dec;21(6):689-700. doi: 10.1177/17407745241247334. Epub 2024 May 16. Clin Trials. 2024. PMID: 38752434 - Bayesian inference with Stan: A tutorial on adding custom distributions.
Annis J, Miller BJ, Palmeri TJ. Annis J, et al. Behav Res Methods. 2017 Jun;49(3):863-886. doi: 10.3758/s13428-016-0746-9. Behav Res Methods. 2017. PMID: 27287444 Free PMC article. - Usage of Compartmental Models in Predicting COVID-19 Outbreaks.
Zhang P, Feng K, Gong Y, Lee J, Lomonaco S, Zhao L. Zhang P, et al. AAPS J. 2022 Sep 2;24(5):98. doi: 10.1208/s12248-022-00743-9. AAPS J. 2022. PMID: 36056223 Free PMC article. Review. - Compartmental structures used in modeling COVID-19: a scoping review.
Kong L, Duan M, Shi J, Hong J, Chang Z, Zhang Z. Kong L, et al. Infect Dis Poverty. 2022 Jun 21;11(1):72. doi: 10.1186/s40249-022-01001-y. Infect Dis Poverty. 2022. PMID: 35729655 Free PMC article. Review.
Cited by
- A vaccination-based COVID-19 model: Analysis and prediction using Hamiltonian Monte Carlo.
Jdid T, Benbrahim M, Kabbaj MN, Naji M. Jdid T, et al. Heliyon. 2024 Sep 23;10(19):e38204. doi: 10.1016/j.heliyon.2024.e38204. eCollection 2024 Oct 15. Heliyon. 2024. PMID: 39391520 Free PMC article. - Modeling the 2014-2015 Vesicular Stomatitis Outbreak in the United States Using an SEIR-SEI Approach.
Humphreys JM, Pelzel-McCluskey AM, Shults PT, Velazquez-Salinas L, Bertram MR, McGregor BL, Cohnstaedt LW, Swanson DA, Scroggs SLP, Fautt C, Mooney A, Peters DPC, Rodriguez LL. Humphreys JM, et al. Viruses. 2024 Aug 18;16(8):1315. doi: 10.3390/v16081315. Viruses. 2024. PMID: 39205289 Free PMC article. - REAL-TIME MECHANISTIC BAYESIAN FORECASTS OF COVID-19 MORTALITY.
Gibson GC, Reich NG, Sheldon D. Gibson GC, et al. Ann Appl Stat. 2023 Sep;17(3):1801-1819. doi: 10.1214/22-aoas1671. Epub 2023 Sep 7. Ann Appl Stat. 2023. PMID: 38983109 Free PMC article. - Bayesian workflow for time-varying transmission in stratified compartmental infectious disease transmission models.
Bouman JA, Hauser A, Grimm SL, Wohlfender M, Bhatt S, Semenova E, Gelman A, Althaus CL, Riou J. Bouman JA, et al. PLoS Comput Biol. 2024 Apr 29;20(4):e1011575. doi: 10.1371/journal.pcbi.1011575. eCollection 2024 Apr. PLoS Comput Biol. 2024. PMID: 38683878 Free PMC article. - Parameter estimation and forecasting with quantified uncertainty for ordinary differential equation models using QuantDiffForecast: A MATLAB toolbox and tutorial.
Chowell G, Bleichrodt A, Luo R. Chowell G, et al. Stat Med. 2024 Apr 30;43(9):1826-1848. doi: 10.1002/sim.10036. Epub 2024 Feb 20. Stat Med. 2024. PMID: 38378161
References
- Flaxman S, Mishra S, Gandy A, et al. Estimating the effects of non‐pharmaceutical interventions on COVID‐19 in Europe. Nature. 2020;584:257‐261. - PubMed
- Keeling M, Danon L. Mathematical modelling of infectious diseases. Br Med Bull. 2009;92:33–42. - PubMed
Publication types
MeSH terms
LinkOut - more resources
Full Text Sources
Medical
Research Materials
Miscellaneous