posterior predictive distribution from brms (logistic regression)
Asked Answered
P

1

9

I'm new to both stan and brms, and having trouble extracting posterior predictive distributions. Let's say I have a simple logistic regression

fit = brm(y ~ x, family="bernoulli", data=df.training)

where y is binary and x continuous. For test data (or even the training data), I thought I could now get hold of the predictive distribution for the bernoulli probability p, by altering probs in

predict(fit, df.test, probs=seq(0, 1, 0.1))

However, while the output from this command gives me estimates that are continuous in the range [0,1] (this makes sense), the confidence interval values seem to be binary (this does not make sense to me)... How do I get the entire posterior predictive distribution for p?

Paripinnate answered 30/10, 2017 at 16:34 Comment(3)
Use the posterior_predict function.Successful
that still returned binary values, however, posterior_linpred(transform=TRUE) actually did what I want... I guess this is only an issue for models where the observables are on a different scale than the actual response variable.Paripinnate
There's also the pp_check function that makes some pretty plots.Losel
S
3

This question is obviously a long time ago. But I stumbled upon it and think it resonates with my own questions.

Based on my experiment on a logistic regression model I think below is true for the default inputs:

  1. posterior_linpred gave the continuous linear scale;
  2. fitted gave the continuous probability scale between 0 and 1;
  3. predict gave the binary [0,1] scale predictions

I don't have a Beta-Binomial model (to me, it is a good example of logistic with over-dispersion) at hand to test what the result of the posterior_linpred would be, but I am confident that the fitted and predict would be on the outcome scale.

Sollie answered 11/4, 2019 at 6:50 Comment(1)
thanks for adding that answer despite the age, that should be a really good starting point for anyone facing similar issue in the future!Paripinnate

© 2022 - 2024 — McMap. All rights reserved.