I have fitted a model using
Since there is no
binomial_logit_rng, I’m wondering what might be the best way to generate predictions.
My main model is:
target += binomial_logit_lupmf(Y | trials, mu);
Is using something like:
prediction[n] = binomial_rng(trials[n], inv_logit(mu_pred[n]));
In generated quantities sufficient? Or would that be missing something?
You’re right that as of 2.30, we still don’t have
binomial_logit_rng. Sorry about that! It’s on our to-do list.
Yes, that will work to give you posterior predictive draws. It’s what
binomial_logit_rng would do internally. It’s more robust than using
inv_logit for sampling because if it underflows to 0 or rounds to 1, you’ll still get sensible output (all 0s or all 1s).
mu_pred are all one dimensional containers (array, vector, or row vector), then you can vectorize as:
array[N] prediction = binomial_rng(trials, inv_logit(mu_pred));