A practical introduction to ODE modelling in Stan for biological systems
2026
Read A practical introduction to ODE modelling in Stan for biological systems (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2603-20343.txt.
Introduction
Hamis and co-authors give a hands-on guide to fitting ODE models in Stan for biology. Matching dynamic models to time series data is central to mathematical biology. Stan is a free tool that estimates model parameters with Bayesian methods. It has built-in support for ordinary differential equation models. Worked examples move from simple teaching models to real data sets. The guide also explains the core statistical ideas behind Stan. Readers can follow each step and reuse the code.
Catalog record
| YEAR | 2026 |
|---|---|
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 79368 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2603.20343
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
A practical introduction to ODE modelling in Stan for biological systems Abstract Integrating dynamical systems models with time series data is a central part of contemporary mathematical biology. With the rich variety of available models and data, numerous methods and computational tools have been developed for these purposes. One such tool is Stan, a freely available and open-source probabilistic programming framework that provides efficient methods for estimating model parameters from data using computational Bayesian inference algorithms. Stan includes built-in mechanisms for working with ordinary differential equation (ODE) models, which are widely used in mathematical biology and related fields to study simulated, experimental, and real-world systems that change over time. Through step-by-step worked examples, including both pedagogical toy models and applications with real data, this article provides a practical, self-contained introduction to performing parameter estimation and model evaluation for first-order linear and nonlinear ODE models in Stan. The article also explains key statistical methods that underpin Stan and discusses computational Bayesian modelling in the context of biological applications. Sara Hamis 1 , John Forslund 1 , Cici Chen Gu 1 , Jodie A. Cochrane 1 . 1 Department of Information Technology, Uppsala University, Uppsala, Sweden. Correspondence: [email protected]. Author ORCIDs: SH (0000-0002-1105-8078); JF (0009-0006-5457-4298); CCG (0009-0008-1998-6486); JC (0000-0001-8259-0478). Keywords: Computational Bayesian inference, Hamiltonian Monte Carlo, probabilistic programming, ordinary differential equations, mathematical biology. 1 Introduction With the recent surge in biological data, integrating mathematical models with empirical observations has become a central part of contemporary mathematical biology. This trend also aligns with the increasing role of model-informed practices in medicine, public health, and environmental sectors [ 31 ] . However, given the rich variety of models and data used in the field, there is no consensus on best practices for parameterising, evaluating, and selecting models with respect to data. Instead, a variety of methods and computational tools have been developed for these purposes. This article focuses on implementing a particular family of models, ordinary differential equation (ODE) models, within the context of probabilistic modelling of dynamical systems in biology, using one such tool: Stan [ 36 ] . Stan is a non-proprietary probabilistic programming framework that provides an efficient way to estimate model parameters from data using computational Bayesian inference algorithms. Given the myriad of available methods for parameter estimation, model evaluation, and model selection, why should a reader then (a) use Stan and (b) read this article? To answer question (a), let us first acknowledge that Stan makes sophisticated Bayesian parameter estimation methods available to researchers who are not specialists in computational statistics. This allows Stan users to focus on other aspects of their research, while Stan is continuously developed and maintained by a dedicated team of experts. Moreover, Stan is open-source and well-documented, making its underlying algorithms transparent and enabling custom extensions of the code base. Despite this, Stan remains underused in mathematical biology. This claim is supported by a citation-data analysis we conducted, revealing that only 15 articles published between Stan’s release in 2012 and 2024 cite Stan across five well-established mathematical biology journals [ 32 ] (Supplementary Material, SM1). This likely reflects the broad trend that frequentist statistics is more widely taught than Bayesian statistics in undergraduate mathematics and statistics programmes [ 16 ] , and that frequentist methods remain more common than Bayesian methods in biomedical research [ 11 , 28 ] . In line with this argument, recent results from a survey-based study addressing the question “Why are there not more Bayesian clinical trials?” suggested that insufficient knowledge of Bayesian methods is one of the main factors hindering their broader implementation [ 8 ] . The 323 respondents were affiliated with pharmaceutical companies (33.4%), clinical research organizations (29.7%), regulatory agencies (18.6%), academia, medical practice, and other. The under-use of Stan in mathematical biology, in particular, may also partly stem from a lack of literature resources that concisely explain how to apply Stan to common types of mathematical biology models in a way that is tailored to researchers in the field. Motivated by this conjecture and the prevalence of ODE models in mathematical biology, this article provides a practical guide to implementing ODE models in Stan, which answers question (b). In its short and practical format, our article is not designed to give readers a full background on ODE models, Bayesian statistics, or Stan. Good resources for these topics already exist, several of which are referenced throughout this article. Instead, our article is intended to be a streamlined introduction to implementing ODE models in Stan. Through worked Stan examples, we will show how to implement ODE models for biological systems whose dynamics are described by one or more linear or nonlinear first-order equations. We will also discuss when and how to use complete, no, and partial pooling approaches, and how to perform model evaluation and selection using posterior predictive checks and estimates of the expected log predictive density. These techniques are conceptually explained in the Background section, and practically demonstrated with code exampled in the Implementation section. Although this article provides a “shortcut to implementation”, it is not intended to replace thorough background reading on the statistical theory that underlies Stan. On the contrary, we hope that once readers see how powerful and easy-to-use Stan is, they will be encouraged to learn more about computational Bayesian statistics. A friendly starting point for this learning is Lambert’s introductory book on Bayesian statistics, which includes worked Stan examples [ 22 ] . A more in-depth, although still introductory, discussion on the methods on which Stan is built is provided by [ 3 ] . In addition, specialised resources on how to use Stan in specific research areas of mathematical biology include articles on pharmacometrics [ 24 ] , epidemiology [ 14 , 7 ] , and ecology [ 21 ] . 2 Background 2.1 Back to basics and Bayes’ rule Our starting point for Bayesian parameter inference is Bayes’ rule in the form p(\theta\mid\mathcal{D})=\frac{p(\mathcal{D}\mid\theta)p(\theta)}{p(\mathcal{D})}, (1) where \mathcal{D} denotes the observed data, and \theta denotes the model parameter(s) whose values we want to infer. If we have j such parameters, then \theta is a vector \theta=(\theta_{1},\theta_{2},...,\theta_{j} ). Eq. ( 1 ) relates the posterior distribution p(\theta\mid\mathcal{D}) to three right-hand side components: the likelihood function p(\mathcal{D}\mid\theta) , the prior distribution p(\theta) , and the normalising constant p(\mathcal{D}) . Fig. 1 conceptually illustrates how these components combine to form the posterior. The main goal of Bayesian inference is to learn the posterior p(\theta\mid\mathcal{D}) , which represents what we believe about the parameter values after letting data inform our model. In contrast, the prior p(\theta) represents our beliefs about the parameter values before this data-informed update. For some applications in mathematical biology, we can leverage knowledge about the modelled system and use informative priors. In other cases, such knowledge is unavailable, and noninformative or weekly informative priors could be more appropriate [ 12 ] . The effect of using informative and noninformative priors is exemplified in Fig. 1 . We now turn to the likelihood p(\mathcal{D}\mid\theta) , which describes how likely it is to have observed the data \mathcal{D} , given a specific model and value of \theta . Note that in our setting, the likelihood incorporates both the ODE model and the error