Example of manually calculating posterior predictions and "epredictions" with posterior draws from brms model?

Does anyone have an example of manually calculating the predictions from posterior_predict.brmsfit and posterior_epred.brmsfit() from the posterior draws themselves in a simple model? I’m having a difficult time understanding exactly how each of these types of posterior predictions are calculated and an example (especially making predictions for one row of data) would be great.

I’m particularly confused about what values/objects from the posterior draws are added/removed to distinguish between the two (i.e. is it just a residual and if so where to find that in the output) and whether the prediction for each draw is deterministic conditional on a set of predictor values (as in using predict() with the output of lm()). I understanding the latter should include residual error excluded from the former, but I’m trying to actually do that myself.

Browsing hanging threads and found this one. The thread should be combined with Expected Value of Posterior vs. Posterior of Expected Value with epred - #2 by scholz and discussions there.

3 Likes