I came across this paper about Randomized Quantile Residuals and have found the idea pretty useful:

I’m using this idea on a mixed effects model with a negative binomial error distribution. On page 9 of the paper linked above, you’ll see the formula I want to calculate in R after the Stan run has been completed. For each observation, I want the associated mu and shape parameters for the negative binomial distribution.

Since brms calculates mu in the Model block, I don’t think Stan will print it (page 101 of the Stan 2.17.0 manual). When I coded models myself, I’d get around this by calculating mu in the Transformed Parameters block. For that matter, if I were to have the shape parameter vary by a class variable, the shape parameter also ends up calculated in the Model block.

So my question: is there a simple way in R to take a brms object and have it spit out the associated mu and shape parameter for each observation?

Thanks,

Paul

- Operating System: windows
- brms Version: 2.2