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
- See the introductory vignette for a tutorial-style introduction to
odin2
- A tutorial-style guide to using
odin2
withdust2
andmonty
to fit models to data - A reference-style guide to the syntax and supported functions
- If you have used
odin
version 1 before, see the migration guide to see what has changed. - Because
odin2
compiles todust2
, see its documentation and in particular the list of functions that you can use
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)