Stock-and-flow models are a computational method from the field of system dynamics. They represent how systems change over time and are mathematically equivalent to ordinary differential equations. 'sdbuildR' (system dynamics builder) provides an intuitive interface for constructing stock-and-flow models without requiring extensive domain knowledge. Models can quickly be simulated and revised, supporting iterative development. 'sdbuildR' simulates models in 'R' and 'Julia', and supports computationally intensive ensemble simulations. Additionally, 'sdbuildR' can import models created in 'Insight Maker' (< https://insightmaker.com/>).
sdbuildR is an R package for building, simulating, and exploring stock-and-flow models. Originating in the field of system dynamics, stock-and-flow models represent processes as quantities (stocks) that accumulate or deplete over time and the processes (inflows and outflows) that change them. sdbuildR is designed to make stock-and-flow modelling accessible to a broad audience, requiring minimal mathematical or system dynamics background knowledge.
Load one of the models from the built-in library, such as the classic SIR (Susceptible-Infected-Recovered) epidemic model:
library(sdbuildR)
# Load stock-and-flow model
sfm <- stockflow("sir")
# View the stock-and-flow diagram
plot(sfm)
# Simulate and visualize the dynamics over time
simulate(sfm) |> plot()

The Get started guide provides a step-by-step tutorial on building and simulating stock-and-flow models using interactive plots.
The release version can be installed from CRAN:
install.packages("sdbuildR")
The development version can be installed from GitHub:
if (!require("remotes")) install.packages("remotes")
remotes::install_github("kcevers/sdbuildR")
sdbuildR is designed to support the iterative process of building, simulating, and testing stock-and-flow models. Models can flexibly be modified and simulated in either R or Julia (see setup guide) for a major speed-up on large or repeated runs. All package capabilities are described in the vignettes:
sdbuildR is heavily based on common system dynamics software such as Vensim, Powersim, Stella, and Insight Maker. To translate xmile models to R, see the R package readsdr. To build stock-and-flow models with the R package deSolve, the book System Dynamics Modeling with R by Jim Duggan will prove useful. In Python, stock-and-flow models are supported by PySD.
sdbuildR is under active development and may have bugs, particularly in
complex model translations. We encourage users to report issues on
GitHub - your input helps
the package improve! Use summary() to run model diagnostics, and use
the vignettes for guidance.
To cite sdbuildR, please use:
citation("sdbuildR")
#> To cite package 'sdbuildR' in publications use:
#>
#> Evers, K. (2026). sdbuildR: An Accessible Interface for
#> Stock-and-Flow Modelling in R. R package version 2.2.2.
#> https://doi.org/10.32614/CRAN.package.sdbuildR
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Manual{sdbuildR,
#> title = {{sdbuildR}: An Accessible Interface for Stock-and-Flow Modelling in R},
#> author = {Kyra Caitlin Evers},
#> year = {2026},
#> note = {R package version 2.2.2},
#> url = {https://kcevers.github.io/sdbuildR/},
#> doi = {10.32614/CRAN.package.sdbuildR},
#> }