Hello,
I have a beta regression where I model both the response and the dispersion, like this:
mean.spec <- as.formula(y ~ ...)
disp.spec <- as.formula(~ ...)
fit <- brm(bf(mean.spec, phi=disp.spec), family=Beta(), ...)
The model fits fine, but when I try to see what dispersion is taken at each observation:
predict(fit, resp="phi")
I get back predictions of the response, i.e. the resp
argument is ignored.
This is likely something quite trivial, but I am stumped. Thank you very much in advance.
Versions:
- Operating System: Windows 10
- brms: 2.9.0
Hi!
The correct way is to use the ‘fitted’ function, using the argument ‘dpar = phi’.
Have a good day!
Lucas
Do not forget that phi is a precision parameter, non linearly and negatively related to dispersion :)
Thank you for your reply, Lucas. Wouldn’t fitted
ignore the random effects and the residual variability though? I care about both in my application.
The argument re_formula
controls this and by default will include all group level effects. See ?brms:::fitted.brmsfit
for details.
Thanks, Lucas and Gavin. fitted
indeed works and includes the group effects, which is sufficient in my case, actually. But what should I do if I also wanted to include the residual variability? The documentation directs me to predict
.
Residual variability applies, by definition, only to the response variable itself. Distributional parameters have no residual variability.
You’re right. Thanks everyone.