library(brms)
library(tidybayes)
library(dplyr)
library(ggplot2)
library(modelr)
mtcars_clean = mtcars %>%
mutate(cyl = ordered(cyl))
m_cyl = brm(
cyl ~ mpg * hp,
data = mtcars_clean,
family = cumulative,
seed = 58393,
prior = c(
prior(normal(0, 35), class = b),
prior(normal(0, 10), class = Intercept)
)
)
preds = mtcars %>%
data_grid(
mpg = seq_range(mpg, n = 10),
hp = seq_range(hp, n = 18)
) %>%
add_epred_rvars(m_cyl, columns_to = "cyl")
preds %>%
ggplot(aes(x = mpg, y = hp, size = mean(.epred), color = cyl)) +
geom_point(position = position_dodge(width = 2.5), shape = 15) +
theme_tidybayes()Created on 2022-04-01 by the reprex package (v2.0.1)
