I had a quick go at this here: Interpolation example · GitHub. You should be able to run the script with python script.py in a python virtual environment with a newish cmdstanpy installed.
I had to do a bit of creative interpretation in order to make a runnable example and I have no idea what the results are meant to look like or what is being modelled, so please treat with caution!
The main thing I wanted to get across is that the ode_* functions with variadic signatures (as opposed to the integrate_ode_* ones that you used in the original post) let you use meaningfully named variables and avoid some packing and unpacking.
It is kind of exactly what I need, If I could modify it with function sir instead of vector sir. Since sir function just accepts x_i and x_r as integers and real data, not a vector . Then If I could define z in the data and transformed data block. Do you have any idea how?
Btw, I am getting an error by running your code in colab. It is finishing the chain but shows error then:/
Hi again! I think input from someone with better knowledge of the specific modelling problem than me is probably needed here. I left out the x_r and x_i inputs as they weren’t used in the original example (x_i was empty and x_r was a copy of Z), made the sir function return a vector because this is what the function ode_rk45 requires and made z a data variable to copy Z from the original example. It could be that details of the problem make it better to go with integrate_ode_rk45 but I can’t really tell.
On the other hand I can definitely help with getting my example to run without errors! I left some comments on the github gist that should help get started.