Hi all,

It seems like questions about Jacobian adjustments come up often enough, so I thought it might be useful to put together an explanation geared towards users who are less comfortable with math: Jacobian adjustments explained simply

This resource illustrates how Jacobian adjustments originally “clicked” for me, and FWIW I’ve received pretty positive feedback on this explanation from another Stan user who was confused by Jacobian adjustments.

The nugget of the explanation is to show how uniform densities transform via nonlinear transformations, and then to motivate the Jacobian adjustment as the term necessary to “flatten out” the starting point for the target density over the transformed parameter. One neat benefit of this line of thinking is that it becomes abundantly clear how deeply the choice of parameterization affects the posterior. I think most users who encounter the `parameters` block for the first time believe that it is a weird syntactic hurdle to tell Stan what variable names to expect later on, when in fact it is far more profound, representing the choice of parameterization and therefore the choice of the implicit improper prior that gets modified by the sampling statements.

Anyhow, hope it’s useful to somebody. Comments/suggestions welcome; here’s the repo for the code.

–Jacob

12 Likes

nicely explained! I’m interested in the followup re encoding information in a non-generative way ;)

1 Like

I like it!

One thing I think that is worth adding is what the actual math of the target (log) density looks like when you have the jacobian adjustment vs not. This could be a bonus section. It’s a bit more math but useful to connect those dots for some people.

2 Likes

Nice explanation. I add here link to my example which illustrates how Jacobian adjustment is related to Stan interfaces, different algorithms and `log_prob` method options in Stan Visual illustration of Jacobian of parameter transformation

3 Likes