Last updated on 2018-09-11 by Karline Soetaert and Thomas Petzoldt

Differential equations (DE) are mathematical equations that describe how a quantity changes as a function of one or several (independent) variables, often time or space. Differential equations play an important role in biology, chemistry, physics, engineering, economy and other disciplines.

Differential equations can be separated into stochastic versus deterministic DEs. Problems can be split into initial value problems versus boundary value problems. One also distinguishes ordinary differential equations from partial differential equations, differential algebraic equations and delay differential equations. All these types of DEs can be solved in R. DE problems can be classified to be either stiff or nonstiff; the former type of problems are much more difficult to solve.

The dynamic models SIG is a suitable mailing list for discussing the use of R for solving differential equation and other dynamic models such as individual-based or agent-based models.

This task view was created to provide an overview on the topic. If we forgot something, or if a new package should be mentioned here, please let us know.

Stochastic Differential Equations (SDEs)

In a stochastic differential equation, the unknown quantity is a stochastic process.
• The package sde provides functions for simulation and inference for stochastic differential equations. It is the accompanying package to the book by Iacus (2008).
• The package pomp contains functions for statistical inference for partially observed Markov processes.
• Packages adaptivetau and GillespieSSA implement Gillespie's "exact" stochastic simulation algorithm (direct method) and several approximate methods.
• The package Sim.DiffProc provides functions for simulation of Itô and Stratonovitch stochastic differential equations.
• Package QPot analyzes 2-dimensional systems of stochastic differential equations using quasi-potential analysis.
• Package rpgm deals about fast simulation especially in Stochastic Differential Equations (SDE) of Itô type. It integrates the Ziggurat method to simulate Normal random variables faster than `rnorm`, the Brownian motion, the Euler and Milstein schemes, and the Gaussian Vasicek process. Multi-core support will be provided.
• Package diffeqr can solve SDE problems using the DifferentialEquations.jl package from the Julia programming language.

Ordinary Differential Equations (ODEs)

In an ODE, the unknown quantity is a function of a single independent variable. Several packages offer to solve ODEs.
• The "odesolve" package was the first to solve ordinary differential equations in R. It contained two integration methods. It has been replaced by the package deSolve.
• The package deSolve contains several solvers for solving ODE, DAE, DDE and PDE. It can deal with stiff and nonstiff problems.
• The package deTestSet contains solvers designed for solving very stiff equations.
• The package odeintr generates and compiles C++ ODE solvers on the fly using Rcpp and Boost odeint.
• Package sundialr provides an interface to the 'SUNDIALS' ODE solvers. Currently the serial version 'CVODE' can be accessed. Models can be written in R or C++ using Rcpp.
• The R package diffeqr provides a seamless interface to the DifferentialEquations.jl package from the Julia programming language. It has unique high performance methods for solving ODE, SDE, DDE, DAE and more. Models can be written in either R or Julia. It requires an installation of the Julia language.
• Package pracma implements several adaptive Runge-Kutta solvers such as ode23, ode23s, ode45, or the Burlisch-Stoer algorithm to obtain numerical solutions to ODEs with higher accuracy.
• Package rODE (inspired from the book of Gould, Tobochnik and Christian, 2016) aims to show physics, math and engineering students how ODE solvers can be made with R's S4 classes.

Delay Differential Equations (DDEs)

In a DDE, the derivative at a certain time is a function of the variable value at a previous time.
• The package PBSddesolve (originally published as "ddesolve") includes a solver for non-stiff DDE problems.
• Functions in the package deSolve can solve both stiff and non-stiff DDE problems.
• Package diffeqr can solve DDE problems using the DifferentialEquations.jl package from the Julia programming language.

Partial Differential Equations (PDEs)

PDEs are differential equations in which the unknown quantity is a function of multiple independent variables. A common classification is into elliptic (time-independent), hyperbolic (time-dependent and wavelike), and parabolic (time-dependent and diffusive) equations. One way to solve them is to rewrite the PDEs as a set of coupled ODEs, and then use an efficient solver.
• The R-package ReacTran provides functions for converting the PDEs into a set of ODEs. Its main target is in the field of ''reactive transport'' modelling, but it can be used to solve PDEs of the three main types. It provides functions for discretising PDEs on cartesian, polar, cylindrical and spherical grids.
• The package deSolve contains dedicated solvers for 1-D, 2-D and 3-D time-varying ODE problems as generated from PDEs (e.g. by ReacTran).
• Solvers for 1-D time varying problems can also be found in the package deTestSet.
• The package rootSolve contains optimized solvers for 1-D, 2-D and 3-D algebraic problems generated from (time-invariant) PDEs. It can thus be used for solving elliptic equations.
Note that, to date, PDEs in R can only be solved using finite differences. At some point, we hope that finite element and spectral methods will become available.

Differential Algebraic Equations (DAEs)

Differential algebraic equations comprise both differential and algebraic terms. An important feature of a DAE is its differentiation index; the higher this index, the more difficult to solve the DAE.
• The package deSolve provides two solvers, that can handle DAEs up to index 3.
• Three more DAE solvers are in the package deTestSet.
• Package diffeqr can solve DAE problems using the DifferentialEquations.jl package from the Julia programming language.

Boundary Value Problems (BVPs)

BVPs have solutions and/or derivative conditions specified at the boundaries of the independent variable.
• Package bvpSolve deals only with this type of equations.
• The package ReacTran can solve BVPs that belong to the class of reactive transport equations.
• Package diffeqr can also solve BVPs using the DifferentialEquations.jl package from the Julia programming language.

Other

• The simecol package provides an interactive environment to implement and simulate dynamic models. Next to DE models, it also provides functions for grid-oriented, individual-based, and particle diffusion models.
• Package scaRabee offers frameworks for simulation and optimization of Pharmacokinetic-Pharmacodynamic Models.
• In the package FME are functions for inverse modelling (fitting to data), sensitivity analysis, identifiability and Monte Carlo Analysis of DE models.
• The package nlmeODE has functions for mixed-effects modelling using differential equations.
• mkin provides routines for fitting kinetic models with one or more state variables to chemical degradation data.
• Package dMod provides functions to generate ODEs of reaction networks, parameter transformations, observation functions, residual functions, etc. It follows the paradigm that derivative information should be used for optimization whenever possible.
• The package CollocInfer implements collocation-inference for continuous-time and discrete-time stochastic processes.
• Root finding, equilibrium and steady-state analysis of ODEs can be done with the package rootSolve.
• The deTestSet package contains many test problems for differential equations.
• The PBSmodelling package adds GUI functions to models.
• phaseR is an R package for the qualitative analysis of one and two dimensional autonomous ODE systems, using phase plane methods.
• Package cOde supports the automatic creation of dynamically linked code for packages deSolve bvpSolve (or a built-in implementation of the sundials cvode solver) from inline C embedded in the R code.
• Package rodeo is an object oriented system and code generator that creates and compiles efficient Fortran code for deSolve from models defined in stoichiomatry matrix notation.
• Package ecolMod contains the figures, data sets and examples from a book on ecological modelling (Soetaert and Herman, 2009).
• primer is a support package for the book of Stevens (2009).

## Packages

### bvpSolve — 1.3.3

Solvers for Boundary Value Problems of Differential Equations

### cOde — 0.4.1

Automated C Code Generation for 'deSolve', 'bvpSolve' and 'Sundials'

### diffeqr — 0.1.1

Solving Differential Equations (ODEs, SDEs, DDEs, DAEs)

### dMod — 0.4.2

Dynamic Modeling and Parameter Estimation in ODE Models

### CollocInfer — 1.0.4

Collocation Inference for Dynamic Systems

### deSolve — 1.21

Solvers for Initial Value Problems of Differential Equations ('ODE', 'DAE', 'DDE')

### deTestSet — 1.1.5

Test Set for Differential Equations

### ecolMod — 1.2.6

"A practical guide to ecological modelling - using R as a simulation platform"

### FME — 1.3.5

A Flexible Modelling Environment for Inverse Modelling, Sensitivity, Identifiability and Monte Carlo Analysis

Tau-Leaping Stochastic Simulation

### GillespieSSA — 0.5-4

Gillespie's Stochastic Simulation Algorithm (SSA)

### mkin — 0.9.47.5

Kinetic Evaluation of Chemical Degradation Data

### nlmeODE — 1.1

Non-linear mixed-effects modelling in nlme using differential equations

### odeintr — 1.7.1

C++ ODE Solvers Compiled on-Demand

### PBSddesolve — 1.12.2

Solver for Delay Differential Equations

### PBSmodelling — 2.68.6

GUI Tools Made Easy: Interact with Models and Explore Data

### phaseR — 2.0

Phase Plane Analysis of One and Two Dimensional Autonomous ODE Systems

### pomp — 1.18

Statistical Inference for Partially Observed Markov Processes

### pracma — 2.2.2

Practical Numerical Math Functions

### primer — 1.0

Functions and data for A Primer of Ecology with R

### rpgm — 1.1.2

Fast Simulation of Normal/Exponential Random Variables and Stochastic Differential Equations / Poisson Processes

### rODE — 0.99.6

Ordinary Differential Equation (ODE) Solvers Written in R Using S4 Classes

### rodeo — 0.7.4

A Code Generator for ODE-Based Models

### ReacTran — 1.4.3.1

Reactive Transport Modelling in 1d, 2d and 3d

### sundialr — 0.1.1

An Interface to 'SUNDIALS' Ordinary Differential Equation (ODE) Solvers

### QPot — 1.1

Quasi-Potential Analysis for Stochastic Differential Equations

### rootSolve — 1.7

Nonlinear Root Finding, Equilibrium and Steady-State Analysis of Ordinary Differential Equations

### scaRabee — 1.1-3

Optimization Toolkit for Pharmacokinetic-Pharmacodynamic Models

### sde — 2.0.15

Simulation and Inference for Stochastic Differential Equations

### Sim.DiffProc — 4.3

Simulation of Diffusion Processes

### simecol — 0.8-12

Simulation of Ecological (and Other) Dynamic Systems