# "jacobian not necessary" for transformed normal location parameter?

**URL:** <https://discourse.mc-stan.org/t/jacobian-not-necessary-for-transformed-normal-location-parameter/4488>\
**Category:** Modeling\
**Tags:** specification\
**Created:** [June 10, 2018, 8:21pm UTC](https://discourse.mc-stan.org/t/jacobian-not-necessary-for-transformed-normal-location-parameter/4488 "2018-06-10T20:21:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![markwh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/markwh/32/1286_2.png) [@markwh](https://discourse.mc-stan.org/u/markwh)\
**Post date:** [June 10, 2018, 8:21pm UTC](https://discourse.mc-stan.org/t/jacobian-not-necessary-for-transformed-normal-location-parameter/4488/1 "2018-06-10T20:21:29Z")

</div>

Section 22.2 of the Stan reference manual mentions that a Jacobian adjustment is not needed when “the transformed parameters are being used rather than given a distribution”. I’m curious how this can be in my specific case where I have something like the following.

```stan

data {
  int<lower=1>n;
  int<lower=1>m;
  vector<lower=0>[m] dA[n];
  vector[m] x[n];
  real<lower=0> sigma;
}

parameters {
  real<lower=0> A0[n];
  vector[m] y;
}

transformed parameters {
  vector[m] mu[n];
  for (i in 1:n) {
    mu[i] = y - log(A0[i] + dA[i]);
  }
}

model {
  for (i in 1:n) {
    x[i] ~ normal(mu[i], sigma);
  }
//...priors...
}

```

The above model would appear to need no Jacobian adjustment, and Stan does not raise any message to that effect. It seems to me that an equivalent model would be to swap `x[i]` with `mu[i]` in the model block; however in that case this would need a Jacobian adjustment. In both cases the pdf is the same (since it’s symmetric for x and mu), so how to understand this difference?

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [June 10, 2018, 8:41pm UTC](https://discourse.mc-stan.org/t/jacobian-not-necessary-for-transformed-normal-location-parameter/4488/2 "2018-06-10T20:41:35Z")

</div>

> [@markwh](#):
>
> so how to understand this difference?

If you are not putting a prior on `mu`, then you still have a valid posterior distribution for `y` and `A0`. Swapping `mu` with `x` in the model block is not an equivalent model even though the normal (log) PDF evaluates to the same number. In the latter case, you would need a Jacobian adjustment because `mu[i]` is a nonlinear function of `A0[i]` and without that adjustment, you would be drawing from a different posterior distribution than the one you intend.

---

<div class="post-metadata">

**Author:** ![markwh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/markwh/32/1286_2.png) [@markwh](https://discourse.mc-stan.org/u/markwh)\
**Post date:** [June 10, 2018, 9:07pm UTC](https://discourse.mc-stan.org/t/jacobian-not-necessary-for-transformed-normal-location-parameter/4488/3 "2018-06-10T21:07:54Z")

</div>

Thanks, that satisfies my curiosity. Just to be clear, I am putting a prior on mu via a normal prior on y and a lognormal prior on A0 + dA. That doesn’t affect the validity of the posterior, correct?

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [June 10, 2018, 9:12pm UTC](https://discourse.mc-stan.org/t/jacobian-not-necessary-for-transformed-normal-location-parameter/4488/4 "2018-06-10T21:12:22Z")

</div>

I, for one, would not really call it a prior on `mu`, since it is a function of `dA[i]`, which is data. You could say that before you observe `da[i]`, your generative model implies that `mu[i]` has some conditional probability whose form depends on the prior distribution you use for `y` and `A0`.
