For irrelevant reasons, I am comparing probability scale training data predictions derived from glm() and stan_glm() logistic regression models. To obtain probability scale predictions from a stan_glm model, I thought I needed to transform from log-odds to probability via the inverse logit.
However, it seems like no transformation is needed for probability scale predictions, as posterior_predict() with no transform function generates the correct probabilities.
I assume I’m missing something obvious, but it would be nice to know why the transformation is not necessary. Or, if that conclusion is wrong, it would be nice to know what is really going on.
Here’s an example of how I’m proceeding:
dat <- data.frame(y = rbinom(500, 1, .75)) glm.pred <- predict(glm(y~1, data=dat), type='response') stan.mod <- stan_glm(y~1, data=dat) stan.pred.0 <- colMeans(posterior_predict(stan.mod)) stan.pred.1 <- colMeans(posterior_predict(stan.mod, fun=stats::plogis)) preds <- cbind(glm.pred, stan.pred.0, stan.pred.1) head(preds)