MyNixOS website logo
Description

Translate Models from System Dynamics Software into 'R'.

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 'Stan'; and inputs to simulate via 'deSolve' as described in Duggan (2016) <doi:10.1007/978-3-319-34043-2>.

readsdr

Codecov testcoverage CRANstatus R-CMD-check

Overview

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.

Installation

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")

Usage

library(readsdr)
filepath <- system.file("models/", "SIR.stmx", package = "readsdr")
mdl      <- read_xmile(filepath) 

For reading Vensim models, they must be exported as .xmile.

Tutorials

For information on how to use this package, please check:

Supported builtins

  • Stella
    • Comparison operators (=, <>)
    • Logical operators (AND, OR, NOT)
    • If Else Then
    • Inequality operators (`<`, `>`)
    • Pulse1
    • Step1
    • Endogenous table functions
    • Smoothing functions2: SMTH1, SMTH3, SMTHN
    • Delay functions: DELAYN
    • Limited support to uni-dimensional arrays. Apply all translation is restricted to numeric values.
    • Math functions: ABS, SQRT
    • Stats functions: NORMAL3
  • Vensim
    • Comparison operators (=, <>)
    • Logical operators (:AND:, :OR:, :NOT:)
    • IF_THEN_ELSE
    • Inequality operators (`<`, `>`)
    • Pulse1
    • Pulse Train1
    • Step1
    • Endogenous table functions
    • Smoothing functions2: SMOOTH, SMOOTH3, SMOOTH3I, SMOOTHI
    • Delay functions: DELAY N
    • Math functions: ABS, SQRT
    • Limited support to bi-dimensional arrays.
    • Stats functions: RANDOM NORMAL3

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.

Notes

  • 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.

Applications

This package has been instrumental in the following works:

  • 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.

Acknowledgments

Thanks to:

  • Rogelio Oliva for advocating the need to create an open-source tool for the System Dynamics community and push forward this endeavour.
  • Sergey Naumov for his ideas to implement several functions in this package.
  • Jim Duggan from whom I borrowed ideas to implement this package.

References

Duggan, J. (2016). System Dynamics Modeling with R. Springer.

Metadata

Version

0.3.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows