Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Jacobian determinants #35

Open
sethaxen opened this issue Jul 20, 2022 · 1 comment
Open

Testing Jacobian determinants #35

sethaxen opened this issue Jul 20, 2022 · 1 comment
Labels
question Further information is requested

Comments

@sethaxen
Copy link
Collaborator

I've been locally testing my Jacobian derivations in Julia with AD, but ideally our Stan implementations would be tested for correctness as well by computing the Jacobian of the actual transforms using AD and comparing its log-abs-det with the log log-abs-det-jac terms returned by the implementations. Is this straightforward to do? This is outside of my Stan expertise.

@sethaxen sethaxen added the question Further information is requested label Jul 20, 2022
@bob-carpenter
Copy link
Collaborator

bob-carpenter commented Jul 20, 2022

To answer you question, if the transforms and adjoint-Jacobian product are expressed as functions, then you can pull their generated C++ out and do that test in C++ using Stan (there's a Jacobian functional, absolute value function, and log determinant function). I would instead suggest adding a few test cases where we know the answer and instead test that the log density computed by Stan is correct. That we can do without opening C++. We can also test that we get the right answer for sampling, which won't be true if the Jacobian adjustment is wrong. Of course, the Jacobian might be subtly wrong, and we probably wouldn't catch that with a probabilistic test like MCMC.

So I guess what I'm saying is that I'd want to do those tests exactly as @sethaxen proposed for C++ production code, but I think it's overkill for this paper. Having said that, I can help show how to do it if you're still interested (the main pain point is getting everything made, so it'd be easier to add it as a standard Stan unit test, so the dev ops is all in place).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants