Posterior_linpred for brms

Hi @paul.buerkner

I’m trying to use posterior_linpred with a brms logisitic regression. Can I just confirm that if I do

posterior_linpred(brms.object, transform=TRUE)

then to get the probability that a single response is 0 o 1 I need to divide by the number of observations for that particular row? It seems like that makes sense but I just want to be sure.

@kuriwaki @mitzimorris

I would recommend using pp_expect(...) instead of posterior_linpred(..., transform = TRUE) but they will yield the same results, which is the posterior of the expected value of the PPD. If the number of trials in the logistic regression is 1, this will indeed correspond to the probabilities.

1 Like

Thank you. Didn’t know about pp_expect – I see it was introduced in brms 2.11 (https://github.com/paul-buerkner/brms/issues/644)

1 Like

It is a new brms method which will eventually be used in rstanarm as well. I prefer it because, for more complex models, the transformed linear predictor is no longer the mean of the response distribution (take the lognormal distribution as an example).

2 Likes

Following up, if its binomial and trials(n) > 1, is there a way to get posterior expectation in probabilities there? (e.g. where trials = 3 and the estimated expectation is 2.5, pp_expect will output 0.83.) I can see you can get these by dividing by the appropriate model$data$n, but we were wondering if there was a way to do that internally.

1 Like

If the information passed to trials is a variable, say n, you can set n = 1 in newdata.

1 Like

That’s a great trick – thank you.

1 Like