Bambi logistic regression, prior and posterior distributions of probabilities

Hi everyone,

I was wondering: when doing a logistic regression in bambi (using family=“bernoulli” as the likelihood), is it possible to easily get prior and posterior distributions of the probabilities passed to the likelihood function or does one need to compute those manually from the prior/posterior distributions of the input variables?

Thanks!

Hi @leomein,

Sorry for the late comment. You can easily get the posterior of the probability of success using the .predict() method in the Model object. Here you have an example.

For the prior you have .prior_predictive(), but it returns values in the scale of the response (0-1 values) not in the scale of the mean.

Let me know if you have any questions about how to use it.

1 Like

Hello! Thanks a lot for that answer and also sorry for the super late reply (hadn’t noticed I’d gotten one). Turns out I was using an older bambi version which didn’t have this functionality, but now it works, thanks again! One question though, can you tell me why these are mean probabilities? I checked the shape of the array and to me it looks like for every datapoint there are as many probabilities as there are draws in the chain.

Thank you!

I think your intuition is right, but I may have used a term that could have confused you.

Each of the posterior values for that probability is a “mean” in the sense it is a mean for the Bernoulli distribution, not in the sense that we have averaged a bunch of values. If you want the “mean probability”, you have to compute the mean of those draws.

Hope it clarifies!

Yes, makes sense, thank you!