Clarification regarding Jacobians - BYM2 model

Let’s strip down even more of the complexity, and just ask about the following three models.

Model 1, which clearly requires no Jacobian adjustement, provided that the goal is to end up with normally distributed log_sigma

parameters{
  real log_sigma;
}
transformed parameters{
  real<lower=0> sigma = exp(log_sigma);
}
model{
  log_sigma ~ std_normal();
}

Model 1.5, which is identical to model 1 (just pointing out that it doesn’t matter if you declare sigma in transformed parameters or locally in model.

parameters{
  real log_sigma;
}
model{
  real sigma = exp(log_sigma);
  log_sigma ~ std_normal();
}

Model 2, which parameterizes in terms of sigma instead of in terms of log_sigma, requires a Jacobian adjustment.

parameters{
  real<lower = 0> sigma;
}
transformed parameters{
  real log_sigma = log(sigma);
}
model{
  log_sigma ~ std_normal();
}

Following the language in the post you linked here, this final model’s parameterization starts out as flat over sigma, which is not flat over log(sigma). It then increments the target by normal_lpdf(log_sigma | 0, 1). If the starting point would have been flat over log_sigma, then this increment would yield a target density that is standard normal over log_sigma. But since the starting point is not flat over log_sigma, we now have defined a target density that is not standard normal over log_sigma, and requires a Jacobian adjustment.

Now let’s consider Model 1 again. Here parameterize such that our starting point is flat over log_sigma. We increment the target by normal_lpdf(log_sigma | 0, 1), and we have a final target that is standard normal. No Jacobian adjustment required.

Edit: I’ve read a bit more closely your earlier posts, and maybe I can add one further clarification. The only thing that controls whether rho or logit_rho is a parameter in this model is which one you declare in the parameters block. This model can be parameterized in terms of rho or in terms of logit_rho. Your choice of parameterization, coupled with which quantity you wish to put a prior on, determines whether or not a Jacobian adjustment is required. Whether rho or logit_rho is used as an argument to some downstream function (even if that function is a probability density function whose arguments we call “parameters”) has no bearing on which one of rho or logit_rho is a parameter in the sense of being use to parameterize the model configuration space. That choice depends solely on which one you choose to declare in the parameters block.

This is a pretty deep and fundamental point, and is one of those things that’s really hard to wrap one’s head around at first but eventually becomes intuitive in hindsight. For more I highly, highly recommend @betanalpha on probability theory: Probability Theory (For Scientists and Engineers)

2 Likes