Skip to contents

odin2 implements a high-level language for describing and implementing ordinary differential equations and difference equations in R. It provides a “domain specific language” (DSL) which looks like R but is compiled directly to C++, using dust2 to solve your system and to provide an interface to particle filters. You can then use monty to fit your models using MCMC.

  • The DSL is declarative reflecting the mathematical nature of the equations.
  • It includes support for equations that involve vectors, matrices and higher dimensional arrays (up to 8!), including a high-level array indexing notation that removes the need for explicit looping.
  • Supports both discrete-time (possibly stochastic) models, as well as continuous-time ODE models.
  • Interpolation functions can be used to include time-varying quantities into the model (piecewise constant, linear and spline interpolation is supported).
  • The equations are analysed before compilation so that parts that do not depend on time are not included in time-dependent calculations.
  • Supports user-supplied parameters for any part of the system.
  • Supports a large number of mathematical functions (see the functions vignette for a complete list).

Documentation

The best place to start for most people is probably the odin & monty book which walks through odin and its context within a wider set of statistical packages.

The package also includes a number of vignettes and other documentation:

Because odin2 compiles to dust2, see its documentation and in particular the list of functions that you can use

Because odin2 is designed for use with monty, see its documentation, especially when fitting models to data or working with the random number generators for stochastic models.

Roadmap

The package is currently ready for use for adventurous users. It will eventually become odin and replace that version on CRAN (i.e., it will simply become version 2.0.0 of odin, and odin2 will cease to be a package name that you will see). It also replaces odin.dust. It exists separately for now to facilitate development and use alongside the original odin.

See this list of missing features from version 1 of odin before using.

Over the next few months we will be expanding the automatic differentiation support, generating code for other host languages and improving the ergonomics of the package.

Installation

Please install from our r-universe:

install.packages(
  "odin2",
  repos = c("https://mrc-ide.r-universe.dev", "https://cloud.r-project.org"))

If you prefer, you can install from GitHub with remotes:

remotes::install_github("mrc-ide/odin2", upgrade = FALSE)

License

MIT © Imperial College of Science, Technology and Medicine