Hi,
Currently I am fitting such normal likelihood model in Stan:
model {
y ~ normal(mu, sigma);
}
where mu and sigma are complex functions of parameters. I am currently thinking about reparamterization the model by directly modeling log(y), but not sure in this scenerio to what degree should I modify my Stan program. For example, could I just add ‘transformed data’ chunk and then using the following code:
data {
int <lower = 0> N;
vector[N] y;
}
transformed data {
real<lower=0> sqrt_J;
vector[N] y_trans = log(y);
}
model {
exp(y_trans) ~ normal(mu, sigma);
}
Thx!
1 Like
If you want to model:
log(y) ~ normal(mu, sigma)
Then you can just use the lognormal
distribution:
y ~ lognormal(mu, sigma);
1 Like
Thanks so much for your kindly reply!
But now Y ~ normal rather than Y ~ lognormal, so I am a little bit confused about the reparamterization.
1 Like
I think there are different things that you might intend here, and it’s worth sorting them out onebyone. In what follows, I mean the exact same thing by mu
and sigma
(i.e. the exact same complex functions of parameters) everywhere I write mu
and sigma
. When I need to introduce other variables, I give them different names.
The question boils down to why you think this reparameterization is a good idea, or what you are trying to accomplish with the reparameterization.

Maybe you want literally the same model, but somehow parameterized in terms of log(y) rather than in terms of y
. This is sorta what it looks like you’re aiming for with your posted code. If so, I think the answer is: No, you do not want this. If y
is normally distributed with some mean and variance that you have expressions for, there is absolutely no way that it would be more convenient or efficient to sample on some other scale that corresponds to a distortion of y
. Normal distributions are nice and easy. Why would you reparameterize to avoid a normal distribution?

In recognition of the undesirability of reparameterizing to avoid a normal distribution, @andrjohns assumes (reasonably enough) that maybe you mean that you actually want to model the logarithm of y
as normal.
This is not a reparameterization, but rather a different model.

Thinking more about the lognormal model (i.e. not just a reparameterization), maybe the problem is that you think y
is distributed lognormally, but you still think that your complex functions that yield mu
and sigma
should yield approximately the mean and sd of y
. In this case, maybe your real question is how to come up with a different pair of functions that might be expected to yield mu_l
and sigma_l
, the approximate mean and sd of log(y).
Does any of these feel like it captures your question well?
4 Likes