Tidybayes can make great-looking plots for the output of Bayesian models, but it’s not clear (as far as I can see) how to do this for different types of models.
So for fixed effects, we can do this (generate model first & look at the variables):
modd1 <- brm(hp ~ mpg + cyl + am + (1 + gear|mpg), data = mtcars)
get_variables(modd1)
modd1 %>%
gather_draws(b_mpg, b_cyl, b_am) %>%
ggplot(aes(y = .variable, x = .value)) +
stat_halfeyeh()
A model that only has a random intercept is described in the vignette (https://cran.r-project.org/web/packages/tidybayes/vignettes/tidy-brms.html#intervals-with-densities) — with the cars data set, smth like this:
modd2 <- brm(hp ~ (1|gear), data = mtcars)
get_variables(modd2)
modd2 %>%
spread_draws(b_Intercept, r_gear[gear,]) %>%
mutate(condition_mean = b_Intercept + r_gear) %>%
ggplot(aes(y = gear, x = condition_mean)) +
stat_halfeye()
But what about the random effects in modd1? Since there is a fixed effect of mpg and random int. & slopes for mpg for each gear, the main intercept (b_Intercept) and b coefficient (b_mpg) have to incorporated somehow, as the inclusion of (1 + gear|mpg) generates offsets from the the main intercept and b coefficient. But how?