Truncated samples from MVN RNG

Is there a way to constrain samples from a multivariate normal rng to be positive so they can be used as a rate parameter to a Poisson? According to the manual, T[L,U] can be added to sample statements, but I don’t see anything about RNGs. Or is there a better way to do something like:

vector[2] y_sim[N];
vector<lower=0>[2] lambda_sim; //getting negative numbers when run
for(i in 1:N) {
lambda_sim = multi_normal_cholesky_rng(mu, sigma)T[0.01,];
y_sim[i,1] = poisson_rng(lambda_sim[1]);
y_sim[i,2] = poisson_rng(lambda_sim[2]);

Stan doesn’t support truncation for multivariate distributions (because their CDFs usually do not have tractable forms). In the bivariate case, you can draw from a truncated univariate normal and then a truncated univariate normal conditional on the realization of the first. Usually what people do when drawing from the positive orthant is to draw log_lambda_sim from a multivariate normal and then set vector[2] lambda_sim = exp(log_lambda_sim); before using lambda_sim.

1 Like