Is it possible to use an user defined function as an argument for another function? I know that base stan functions such as integrate_ode_rk45 take the user defined ODE function as an argument. Not sure how to write similar function in Stan.
Edit: No (I misunderstood what you were asking at first).
That’s a shame. It would make lives easier if such functionality was available in stan.
You can do more or less the same thing if you #include
your own C++ file in a Stan program. Just define your user-defined function in C++ and call it from your C++ function that you declare but don’t defined in your Stan program.
Yes, it would. We take pull requests if you’d like to add it. But I have to warn you that the parser is a beast to deal with due to the Boost Spirit Qi parser.
Otherwise, you’re going to have to wait until we get around to it. It’s on the roadmap after tuple types and ragged arrays.
Based on the past posts, it sounds like there was no way to write in “pure” stan a user-defined function that took another user-defined function as an argument. These posts were almost 5 years ago. I was writing to ask if that functionality has been added to stan since that time.
Thank you for your consideration.