Hi. What exactly is going on if I declare a lower for a parameter?
mu ~ exponential(1); // what is going on?
y ~ exponential(mu);
For the line for
mu, what exactly is going on? Is it the same as
mu ~ exponential(1)T[a,] ?
The documentation page on Constraint Transforms may be helpful.
When you declare something like a lower bound, what that is telling Stan is that it needs to take the parameter
mu (which in algorithms like HMC must be unbounded) and transform it into one which is greater than
a. We do that by computing
exp(mu) + a, which is then used for the rest of the program as the value for
Because this is a non-linear transformation, it also applies an adjustment term so that the gradient is correct.
Does this mean declaring a bound on a parameter in Stan is not identical to performing rejection sampling for that parameter or sampling that parameter from a truncated distribution?
The distribution Stan samples from is identical to a truncated distribution. The algorithm Stan uses to sample from that distribution is not rejection sampling.