knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of readsdr is to bridge the design capabilities from specialised System Dynamics software with the powerful numerical tools offered by R libraries. The package accomplishes this goal by parsing .xmile files (Vensim and Stella models) into R objects to construct networks (graph theory), ODE functions for deSolve and Stan.
You can install the released version of readsdr from CRAN with:
install.packages("readsdr")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("jandraor/readsdr")
library(readsdr) filepath <- system.file("models/", "SIR.stmx", package = "readsdr") mdl <- read_xmile(filepath)
Vensim models can only be read if they are exported in the .xmile format. Sometimes, Vensim .xmile files can be problematic, where some stocks may not have flows, and flow equations are put as initial values. One way to address this issue is by copying the .mdl file to a different folder and exporting the .xmile file again. If you encounter this issue, please let the developers know at Vensim's forum.
For information on how to use this package, please check:
=
, <>
)AND
, OR
, NOT
) If Else Then
<
, >
)Pulse
^1^Step
^1^SMTH1
, SMTH3
, SMTHN
DELAYN
ABS
, EXP
, SQRT
NORMAL
^3^=
, <>
):AND:
, :OR:
, :NOT:
) IF_THEN_ELSE
<
, >
) Pulse
^1^Pulse Train
^1^Step
^1^SMOOTH
, SMOOTH3
, SMOOTH3I
, SMOOTHI
DELAY N
ABS
, EXP
, SQRT
RANDOM NORMAL
^3^^1^ Restricted to Euler integration.
^2^ These functions cannot be part of more complex mathematical expressions. That is, the auxiliary variable must only contain one smoothing function and nothing else.
^3^ Seed is ignored.
uniflow and non-negative stock features from Stella are not supported.
No built-in is supported for translations to Stan code.
Modules from Stella are not supported.
This package has been instrumental in the following works:
Andrade et al (2024). Preparing for pandemic response in the context of limited resources. System Dynamics Review.
Andrade & Duggan (2023). Anchoring the mean generation time in the SEIR to mitigate biases in $\Re_0$ estimates due to uncertainty in the distribution of the epidemiological delays. Royal Society Open Science.
Andrade & Duggan (2022). Inferring the effective reproductive number from deterministic and semi-deterministic compartmental models using incidence and mobility data. PLOS Computational Biology.
Andrade & Duggan (2021). A Bayesian approach to calibrate system dynamics models using Hamiltonian Monte Carlo. System Dynamics Review.
Andrade & Duggan (2020). An evaluation of Hamiltonian Monte Carlo performance to calibrate age-structured compartmental SEIR models to incidence data. Epidemics.
Thanks to:
Duggan, J. (2016). System Dynamics Modeling with R. Springer.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.