Reproduce posterior_predict from posterior_linpred for a neg binom spline model

Hi Angelo, here’s a brief explanation of the difference. Suppose you have a negative binomial regression with a log link:

\eta_i = a + bx_i \\ \lambda_i = \exp(\eta_i) \\ y_i \sim {\rm NegBinom}(\lambda_i, \phi)
  • posterior_linpred() gives you posterior draws of \eta.
  • posterior_linpred(transform=TRUE), or equivalently posterior_epred(), gives you posterior draws of \lambda, that is, it does the inverse link transformation for you.
  • posterior_predict() gives you draws from {\rm NegBinom}(\lambda, \phi), that is it uses a NegBinom random number generator and includes the dispersion information in \phi.

What do you get if you compare the means instead of the medians?

8 Likes