Sampling from truncated normal distribution

Hello all,

I have a question , suppose I am running the following regression:

data {
vector[N] Y;
vector[N] X;
}

parameters {
real alpha;
real<lower=0> sigma_y;
real beta;
vector<lower=0>[N] u;
real<lower=0> sigma_u;
}

model {
alpha ~ normal(0,2);
sigma_y ~ inv_gamma(1,1);
sigma_u ~ inv_gamma(1,1);
u ~ normal (0, sigma_u);
Y ~ normal(alpha + X*beta - u, sigma);

}

The variable of interest is u, which is assumed to be N(0, sigma_u) T[0,] .

Now in the above model I have ommited T[0,] for u.

I am wondering if I declare the vector u to be vector<lower=0>[N] u, then is there any point in adding T[0,]?

Shouldn’t both this specification should draw the same samples for u?

Any suggestions will be highly appreciated.

Regards
Antony

Can comebody please help here!

The truncation is redundant to the lower bound in the declaration, and most folks use just the latter (I think bc that causes Stan to make a hidden unbounded parameter behind the scenes that it then transforms to achieve the desired bound, yielding proposals guaranteed to meet the constraints, in contrast to declaring only the truncation which would cause proposals outside the desired constraint that then get rejected, yielding wasted computation)

1 Like

Thanks Mike once again. So T[0,] is the recommended option from both the accuracy and efficiency point of view?

No, setting the bound in the parameter-block declaration is the recommended approach. Sorry, I belatedly realize my use of “latter” was confusing given I used a different order in referring to the two approaches than you did.

3 Likes

Thank you Mike for clarifying. This real helps.

Thanks once again!
Antony