Hi Funko, thanks for your reply. Since you asked, what happened, from what I can tell, is that the ODE solver (both rk45 and adams are susceptible, adams less so than rk45) was evaluating the derivatives at time points that were spaced relatively far apart, because the solution was very smooth in those regions. However, there are forcing events which can happen in a short time window, and if the forcing events are between two derivative evaluations, the ODE solver doesn’t see it at all, and the solution is computed as if that event never happened.
The observable symptom was that the solution sometimes had all the bumps (effects of the forcing events) and sometimes some of the bumps were missing. The likelihood function in this model is effectively just the mean-square error between the computed solution and some given data points, so when bumps are included or excluded, it makes for jumps in the MSE, which could occur for only slightly different parameter values.
So the likelihood is bumpy, which, I surmise, leads to problems in sampling. The sampling behavior I observed was that each chain would get stuck at one parameter value, and the sampler would take microscopic steps (several orders of magnitude too small) around that.
I was calling the ODE solver one time with a list of times for which the output is required (1152 intervals of 5 minutes each). I printed out the times at which the derivatives were evaluated and that’s how I found the solver was skipping over some event times (events happen within one 5 minute window). I changed it so that the ODE solver was called 1152 times, once for each 5 minute interval, with the previous solution as the initial conditions and asking for output at only one time, namely t + 5 minutes.
When I call the solver once for each interval, that ensures all events are detected, and the likelihood function is smooth, and the chains are happy.
I wonder how to help people avoid this problem. Maybe the ODE solver can have a secondary output which is the list of times at which the derivatives were evaluated? Just thinking out loud here. The problem I see is that if people supply a list of times for which they want the solutions, they might incorrectly assume that the derivatives will be evaluated at those times – that is the incorrect assumption which I made. Maybe there is some way to advertise that’s not the case.
Thanks for your interest, and all the best.
Robert Dodier