Tutorials
These worked examples build complete models from the package's components and fit them with Turing. Most use real epidemic surveillance data and recreate published analyses. The Gaussian-process study instead fits data simulated from the model itself, where the point is to recover a known truth. Each one is self-contained and runs when the documentation is built, so the numbers you see are produced by the code on the page.
Sampling settings
To keep the documentation build to a sensible time, these tutorials draw moderate NUTS samples, two chains of 200-300 draws each, run in parallel with MCMCThreads(). The target acceptance rate (adapt_delta) has been raised across these tutorials to avoid divergent transitions. That is enough to demonstrate the models and produce stable figures. A real analysis would use more draws and check convergence diagnostics carefully.
To fit a renewal model to reported cases, start with Renewal model with negative-binomial reporting. Follow it with Reporting delays and day-of-week effects for a realistic observation process.
The table groups the pages by theme. The infection, observation, and latent themes are the package's three component roles. Those names are also used on the Composable design page and in the Public API. A page covering more than one theme appears under each.
| Theme | Tutorials |
|---|---|
| End-to-end worked examples | Renewal with negative-binomial reporting, Reporting delays and day-of-week effects, An SIR compartmental model |
| Infection processes | Renewal with negative-binomial reporting, Renewal modifiers, An SIR compartmental model, Declarative compartmental models, Coupled patch models |
| Observation models | Reporting delays and day-of-week effects, Real-time nowcasting, Multiple observation streams |
| Latent processes | A Gaussian-process latent process, Time-varying damping in an AR process, Renewal with negative-binomial reporting |
| Multiple strata and groups | Multiple observation streams, Partial pooling across groups, Coupled patch models |
| Mechanistic and ODE models | An SIR compartmental model, Declarative compartmental models |
| Nowcasting and forecasting | Real-time nowcasting, Renewal with negative-binomial reporting |
The tutorials
Renewal model with negative-binomial reporting. A time-varying reproduction number
driven by an autoregressive latent process, mapped to infections through the renewal equation and observed with overdispersed counts. This is the canonical renewal model of Cori et al. [1] and Mishra et al. [2]. Reporting delays and day-of-week effects. The same renewal core wrapped in an observation model that convolves infections through reporting delays and modulates them with a day-of-week reporting pattern, in the style of real-time estimation tools [3].
Real-time nowcasting: correcting right-truncation. The same renewal core fit to a right-truncated real-time snapshot, contrasting a naive fit (which shows the artefactual recent-
down-turn) with a RightTruncate-corrected fit that removes it, again following real-time estimation practice [3].Multiple observation streams: cases, deaths, and strata. One renewal infection process observed through several named streams with a single
Splitconstruct, covering parallel streams (cases and deaths off shared infections), a cascade (deaths downstream of reported cases, achieved by placing the split lower in the pipeline), and data-driven strata (one stream per age band), motivated by the differing biases of surveillance streams [4].An SIR compartmental model. An alternative infection process where dynamics come from an ordinary differential equation solved by the SciML stack [5], following the Bayesian compartmental-inference example of Chatzilena et al. [6].
Declarative compartmental models with Catalyst. The same SIR dynamics declared as a Catalyst.jl reaction network [7] instead of a hand-written vector field, so the ODE system and its Jacobian are generated rather than maintained by hand.
A Gaussian-process latent process. Plugs a Hilbert-space approximate Gaussian process [8] into the renewal model as the latent
process, fits it under NUTS with Mooncake, and checks it against an exact GP and against the simulated latent. Time-varying damping in an AR process. The same autoregressive latent process with its damping coefficient itself allowed to vary over time, so the amount of mean reversion in
is learned rather than fixed. Partial pooling across groups. A panel of groups sharing one infection process structure but with group-level parameters drawn from a common population distribution, so information is pooled across groups without forcing them to be identical.
Coupled patch models. Several patches over one time axis, built a layer at a time, from independent patches to a shared partially pooled process to a mixing matrix that moves infection pressure between them. The finished model is fit to data simulated from itself, and the coupling is then swapped for a
Gravitymodel and for one written as a single method.Renewal modifiers: depletion and importation. One delayed renewal process compared against the same process extended with
SusceptibleDepletionandImportedCases, so each modifier's contribution is visible against a shared baseline.
Every example uses the same recipe. Assemble components into a model, call as_turing_model on it, simulate by passing missing data, and fit by passing observed data and sampling. Because the components share one interface, you swap a modelling assumption by swapping a struct. The Composable design page explains the mechanism.
References
The methods these tutorials recreate and adapt are described in the following works. Individual pages link back to the relevant entries here. 2. A. Cori, N. M. Ferguson, C. Fraser and S. Cauchemez. A new framework and software to estimate time-varying reproduction numbers during epidemics. American Journal of Epidemiology 178, 1505–1512 (2013).
S. Mishra, T. Berah, T. A. Mellan, H. J. Unwin, M. A. Vollmer, K. V. Parag, A. Gandy, S. Flaxman and S. Bhatt. On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective, arXiv preprint arXiv:2006.16487 (2020).
S. Abbott, J. Hellewell, R. N. Thompson, K. Sherratt, H. P. Gibbs, N. I. Bosse, J. D. Munday, S. Meakin, E. L. Doughty, J. Y. Chun and others. Estimating the time-varying reproduction number of SARS-CoV-2 using national and subnational case counts. Wellcome Open Research 5, 112 (2020).
K. Sherratt, S. Abbott, S. R. Meakin, J. Hellewell, J. D. Munday, N. Bosse, M. Jit and S. Funk. Exploring surveillance data biases when estimating the reproduction number: with insights into subpopulation transmission of COVID-19 in England. Philosophical Transactions of the Royal Society B 376, 20200283 (2021).
C. Rackauckas and Q. Nie. DifferentialEquations.jl – a performant and feature-rich ecosystem for solving differential equations in Julia. Journal of Open Research Software 5 (2017).
A. Chatzilena, E. van Leeuwen, O. Ratmann, M. Baguelin and N. Demiris. Contemporary statistical inference for infectious disease models using Stan. Epidemics 29, 100367 (2019).
T. E. Loman, Y. Ma, V. Ilin, S. Gowda, N. Korsbo, N. Yewale, C. Rackauckas and S. A. Isaacson. Catalyst: Fast and flexible modeling of reaction networks. PLoS Computational Biology 19, e1011530 (2023).
G. Riutort-Mayol, P.-C. Bürkner, M. R. Andersen, A. Solin and A. Vehtari. Practical Hilbert space approximate Bayesian Gaussian processes for probabilistic programming. Statistics and Computing 33, 17 (2023).
K. Charniga, S. W. Park, A. R. Akhmetzhanov, A. Cori, J. Dushoff, S. Funk and others. Best practices for estimating and reporting epidemiological delay distributions of infectious diseases. PLoS Computational Biology 20, e1012520 (2024).
A. Solin and S. Särkkä. Hilbert space methods for reduced-rank Gaussian process regression. Statistics and Computing 30, 419–446 (2020).