I’m using Stan to fit two variables x and y to some expressions using the binomial distribution. Since Stan can’t handle discrete x/y as parameters (right?), I figured I would approximate the problem using a continuous version of the binomial distribution: target += lchoose(x, data) + data * ln(y) + (x - data) * ln(1 - y)
.
(Actual example is somewhat more complex, but this suffices for the explanation).
That’s working fine, but now I want to create a posterior predictive distribution using the same process:
generated quantities {
real future;
future = binomial_rng(x, y);
}
But that’s not working because binomial_rng
only takes an integer for the first parameter. There doesn’t appear to be a real to int casting operation in Stan, which would be an okay approximation. I also didn’t find a way to generate this. Can you help me with this?
The only alternative I currently see is to generate all probabilities and draw from that as a post-processing step outside of Stan.