Hello,
I’m trying to do something that should be quite simple, but I’m not really sure of how to do it correctly.
For visualisation purpose, I want to plot the mean and credibility interval of the fitted probabilities, along with the raw data of probabilities, for each category of my fixed effect.
Here is an example with an open dataset :
library('mtcars')
mtcars$factor_carb <- as.factor(mtcars$carb)
mtcars$fact_am <- as.factor(mtcars$am)
# Fit the model
fit <- brm(mpg ~ 0 + fact_carb + hp + (1|fact_am), data = mtcars, family = gaussian(), chains = 2, iter = 1000)
# Extract the fitted values
fitted_values <- fitted(fit)
And then I want fitted_values, but summurized by fact_carb.
Is there a way to do this ?
Thank you very much !