Doubt in setting bounds for the variables/parameters

Hi Everyone,

If I have a precision parameter and I want its value to be greater than zero, then does the following definition work?

real <lower = 0> alp_prec; [or it should be lower >0 ?]

or should I use something like this,

real<lower=0.0001> alp_prec;

Which is the correct way to set the bounds?


The bounds in Stan are inclusive, so in your example, zero is a possibility if there is underflow. However, if the model is putting positive probability on values so close to zero, you will likely see divergent transitions and need to tweak your model anyway. And that will happen whether you set the lower bound to zero or something slightly larger. So, I would just do

real<lower = 0> alp_prec;
1 Like

Hi @bgoodri,

I have a few more of these precision parameters. When I used [real<lower = 0> alp_prec;], I got an error in the output which said log(0) is negative infinity and hence I had to reset initial values.

When I changed to real<lower = 0.001> alp_prec; , I got the output.