and replace the respective on in Stan-math (sitting under cmdstan/stan/lib/stan_math/…)? I hope this will make things work for you.
Should this work, then I need to build back a lot of changes I made in a speculative way… at which point I would ask you once more to test if you don’t mind.
Thank you for your efforts. I have attempted a longer MCMC run but I’m afraid the errors persist. I attach a screenshot below. A couple of points:
The error code changes to “-3” after using the debugged .hpp files. Previously the error would show “-1”, please refer to my screenshots above.
Given that my daily time series consists of 395 points, I miss why I receive an error message for “data[397] is inf, but must be finite” (see middle of screenshot).
I’d assume going forward with the above version is an improvement. This version does run without these Inf error messages for the example from @Teddy_Groves1 . However, the sampler only produces divergent transitions on that example still. Nevertheless, I must point out that the older rc2 version is not part of the ODE testing framework… which is the released version is. Thus, I do trust the released code more at the moment, given that the new code is far better tested.
I hope the above code also addresses your problems.
Best,
Sebastian
EDIT: Things are a bit urgent as I would love to include the changes in the about to be released 2.28.1. So testing now and iterating would be great. From my view all unit tests pass and the Inf error vanished, which means we have an improvement as it looks.
… and… does the famous rc2 version of the adjoint solver produce results which you trust?
EDIT: At the moment I am really not sure if we mess something up on the Stan side or if the adjoint solver is not being used correctly or even outputs non-sense. Again, our unit tests are quite massive and they do pass.
Sure, I’ve added an .html file in the same folder with the model description, data and initial. Just open it with your browser and let me know of any questions.
does the famous rc2 version of the adjoint solver produce results which you trust?
So far I have only tested “cmdstan-2.27.0” and “cmdstan-ode-adjoint-v2”. How do I access the 2.27.0-rc2 version? I see that 2.28.0-rc2 was made available recently, if this is what you are refering to.
Thanks for the model description… I would like to have a stan model file, a data file and an init file. That’s a lot easier for me to handle rather than running a script with many dependencies. Thanks!
Thanks a lot for this work @wds15 - I have tried the files you linked and this also removes the Inf errors for me. On Monday I should be able to update my repo with a less problematic model configuration, or at least one that seems to work ok with the bdf solver.
I copied the contents of the files cvodes_integrator_adjoint.hpp & ode_adjoint.hpp from the branch to the respective files in my cmdstan-2.27.0 installation. Tested on the same model , but the same errors persist.
Happy to discuss further once the testing on the toy example is completed from your end.
We should definitely now start with a model which runs ok - but slow - with one of the existing forward solvers (bdf or rk45)… and then switch to adjoint.
Given that we struggle that much it would also make sense to go back to the SBC simulation I wrote a while ago. That simulation showed that the Adjoint ODE implementation at the time was OK.
For now, I do think that the changes made in the branch are an improvement and I’d hope that @stevebronder finds the time to review them so that it is included in 2.28.1 for now. It seems we need to investigate further apparently.
We should definitely now start with a model which runs ok - but slow - with one of the existing forward solvers (bdf or rk45)… and then switch to adjoint.
Cool! Posterior outputs for the single-type SIR model with a time-varying effective contact rate (trapezoidal rule) are available. It’s slow, but it is indeed working nicely. Aiming to extend to a multi-type SIR, we take a step back and wish to examine the performance of the single-type SIR with the adjoint solver first. This implementation fails, with the errors reported earlier in this thread.
For now, I do think that the changes made in the branch are an improvement and I’d hope that @stevebronder finds the time to review them so that it is included in 2.28.1 for now. It seems we need to investigate further apparently.
… and this is great news! At this stage, I am trying to cross out possible reasons from my list as to why the single-type SIR model implementation with the adjoint solver fails. I.e. is it the solver itself that struggles for this model, etc. Or it might be the case that the route proposed by @Funko_Unko should be followed, see also the CoDatMo thread.
I was trying to replicate this locally but getting compiler errors because some of the vectors do not have dimensions. You can also dump the data and init into the folder such as
Can you double check you are running the same file as the one in your repo I’ve linked below
In that stan program you have data with no size which is illegal syntax in Stan. i.e. there should be a [whatever_size_abs_tol_backward_is] on the line vector abs_tol_backward; like