[R-sig-dyn-mod] LSODA in R vs ode23s Matlab

John Harrold john.m.harrold at gmail.com
Sun Jun 11 03:18:35 CEST 2017


Howdy Folks,

So I've got a bunch of tools that I use in Matlab for solving odes,
and I've been working on moving all this over to R. I'm generating my
models in C both in Matlab (Simulink/S-Functions) and in R. The good
news is that I've managed to get my stuff in R working faster than the
code in Matlab. Now to be fair to Matlab, I'm using code I wrote years
ago and I've put a bit of effort in to optimizing the R version.

I recently ran into an issue while doing some Monte Carlo type
simulations. About 5-20% of them were failing with integration errors
like:

DLSODA-  Warning..Internal T (=R1) and H (=R2) are
       such that in the machine, T + H = T on the next step
      (H = step size). Solver will continue anyway.

I understand what's going on here. Since I'm automatically generating
code, I switched over to Matlab, loaded the parameters that I was
using in R, and ran it over there using ode23s. It was slower in
Matlab (using compiled C in both places), but I was able to run it.
While it appears to be slower, Matlab seems to be more robust.

I'm planning on trying to generate some examples I can distribute, but
I was wondering if anyone here had any similar examples? Is anyone
familiar with any comparisons of the Matlab solvers as compared to R?
Is anyone interested in doing something like this?


Thanks
John



More information about the R-sig-dynamic-models mailing list