dde v1.0.1


Monthly downloads



Solve Delay Differential Equations

Solves ordinary and delay differential equations, where the objective function is written in either R or C. Suitable only for non-stiff equations, the solver uses a 'Dormand-Prince' method that allows interpolation of the solution at any point. This approach is as described by Hairer, Norsett and Wanner (1993) <ISBN:3540604529>. Support is also included for iterating difference equations.



Project Status: Active – The project has reached a stable, usable state and is being actively developed. Travis-CI Build Status AppVeyor Build status codecov.io

This package solves ordinary differential equations (ODEs), delay differential equations (DDEs) and discrete-time difference (or recursion) equations, perhaps involving delays.

For all the solvers, the target function can be an R function or a compiled function.

Ordinary and delay differential equations

ODEs are solved with DOPRI5 and DOP853; the 5th order and 8th order Dormand Prince methods Dormand Prince, based off of Ernst Hairer's Fortran implementations, but implemented in C. These integrators support dense output.

To solve DDEs, I use the same approach as Hairer in his RETARD algorithm, exploiting the dense output of the Dormand Prince solvers.

This is an alternative approach to fitting delay DDE models to using deSolve. It exists because I have had problems fitting very large DDE systems in deSolve, possibly because the order of interpolation is lower than the order of integration which can cause problems with the overall accuracy of the solution.

By using the dense output, the solution can be computed at any time point the solver has passed to the same accuracy as the solution itself. This sidesteps the interpolation problem at the cost of a bit more book-keeping.

To store the history without using ever-growing (or just huge) amounts of memory, dde uses a ring buffer to hold the history over time. This means that the memory required to store the solution does not grow as the total integration length increases (though you still need to pick an amount of memory that scales with the maximum number of steps that span your longest lag at any point in the integration).

These solvers are suitable only for non-stiff problems.

The interface is fairly different to the deSolve interface. A deSolve compatible interface may be provided later (see this issue).

Discrete time models

Solving discrete time equations is much simpler; you don't have much choice but just to iterate the model. The package implements this efficiently for compiled models, and also allows models to reference their previous history.


Install dde from CRAN with


To install our internally released version (which might be ahead of CRAN) via drat, use

# install.packages("drat") # (if needed)

or install the bleeding edge with

# install.packages("devtools") # (if needed)
devtools::install_gitub("mrc-ide/dde", upgrade = FALSE)


MIT © Imperial College of Science, Technology and Medicine

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Functions in dde

Name Description
difeq_replicate Solve difference equations repeatedly
dopri_interpolate Interpolate Dormand-Prince output
difeq Solve difference equation
dopri Integrate ODE/DDE with dopri
No Results!

Vignettes of dde

No Results!

Last month downloads


License MIT + file LICENSE
URL https://github.com/mrc-ide/dde
BugReports https://github.com/mrc-ide/dde/issues
LinkingTo ring (>= 1.0.0)
RoxygenNote 6.1.1
VignetteBuilder knitr
Encoding UTF-8
Language en-GB
NeedsCompilation yes
Packaged 2020-01-14 15:02:15 UTC; rich
Repository CRAN
Date/Publication 2020-01-16 23:20:05 UTC

Include our badge in your README