parameters {
real foo;
}
transformed parameters {
real bar = f(foo);
}
model {
bar ~ distribution();
}
versus:
parameters {
real foo;
}
model {
real bar = f(foo);
bar ~ distribution();
}
The only real difference I notice is that in the first case, I get bar on the output, which may or may not be desirable. Is that it? Or is there something more interesting going on under that hood computationally that would make either of the variants preferred?
There’s one more thing I can think of. In the transformed parameters you can use _jacobian functions to increment the Jacobian whereas you have to use _lp functions in the model block to increment the target log density (which is the sum of the change-of-variables density and the density defined in the model block). Those can have slightly different behavior under optimization where there’s a flag to disable the Jacobian.