I’d like to expose model Hessians to R through Rstan with something like
grad_log_prob. I have been told by Mike B that the Stan team doesn’t want to do this in a full release because the autodiff Hessians aren’t ready for all models, so I’m happy to hack it up myself in a custom branch. But I think I need some additional guidance.
Looking at the rstan source, it appears that
stan_fit.hpp is the first step in exposing C++ functions to R. So I would like to write my own version of
SEXP grad_log_prob(SEXP upar, SEXP jacobian_adjust_transform)
However, in the Stan model C++ code,
stan::model::log_prob_grad appears to have a different structure than
In particular, I’m not quite sure how to pass the arguments (
par_i in the log_prob_grad function) into the Hessian. The unit test appears to use a
Upon seeing this, I thought maybe I had better just ask for help. :P Can you someone give me a hand figuring this out?