After a challenging development process we are happy to announce that Stan finally supports stiff ODE systems, removing one of the key obstacles in fields such as pharmacometrics and ecology. For the experts, we’ve incorporated CVODE 2.8.2 into Stan and exposed the backward-differentiation formula solver using Newton iterations and a banded Jacobian computed exactly using our autodiff.
Right now the code is available on the develop
branches of the Stan library and the CmdStan interface, with more interface support hopefully coming soon. All you have to do is download develop
from GitHub and compile your model — the CVODE library will automatically compile and install.
The new solver is used similarly to the current integrate_ode function in Stan, only you have to explicitly specify the relative and absolute tolerances and the maximum number of steps,
integrate_ode_cvode(ode, y0, t0, ts, theta, x_real, x_int, rel_tol, abs_tol, max_num_steps)
Be warned that these arguments can have a strong influence on the overall performance of the integrator, so care must be taken in choosing values that ensure accurate solutions. We’ve found that rel_tol = abs_tol = 1e-10
and max_num_steps = 1e8
have worked well for our tests.
If you get a chance to play around with the new solver then do let us know how it performs. Without your feedback, both positive and negative, we can’t make Stan better!
Cool! Do you know anyone who’s worked with PDEs and Stan? Eg seni-discretised first and solved (or amy other way).
n->m, m->n
Not at the moment — the principle of autodiffing the differential system is the same, but the solvers are much more difficult. But if there are any PDE experts out there looking to use Stan we’re all ears.
We have been working on PDEs, SPDE’s – see my website for papers – and have carried out Bayesian inference over ODEs and (elliptic and parabolic) PDE’s in a number of application domains – see the Science ~Sig paper.
Thanks!
Hi Mark, Can you be a bit more explicit about which papers? I don’t know what you mean by the “Science ~Sig” paper. Thanks.