Hi,

I am trying to implement Generalized Fiducial Inference into STAN. I was wondering if there already exists a function to calculate the Jacobian.

Hi,

I am trying to implement Generalized Fiducial Inference into STAN. I was wondering if there already exists a function to calculate the Jacobian.

There is such a function in the Stan Math Library, but it is not exposed to the Stan language. So, you would either need to define your own C++ function that uses it or write the derivatives out in the Stan language. Let us know how it goes. I have never been able to figure out why someone would want to do GFI, but also always thought you would need to use Stan in order to do it.

I could also use a Jacobian function. It should be much faster to call the c++ function, right? Any pointers (maybe an analogous example) would also be welcome :)

Not sure what you mean by the C++ function. Everything’s C++, right?

The fastest thing to do is implement your own analytic derivatives rather than use nested autodiff. You can see that in all of our internal functions. There are helpers in `rev`

like `precomputed_gradients`

, `operands_and_partials`

, and `adj_jac_apply`

depending on what you’re trying to implement.

You’ll also need ones that are fully templated to deal with all the `double`

and `int`

instantiations and to deal with `fvar`

if you want to add this to Stan itself.