How to edit pp_check plot of brms?

Couldn’t figure out how to edit pp_check plots.

How can I change two things on the plot?

  1. Point size of yrep on the plot?
  2. Column/bar width?


n = 100
a = tibble(sex = rep(c("m", "m", "m", "m", "m", "m", "m", "f", "f", "f"), length.out = n), year = rep(c(3, 4, 5), length.out = n))
b = tibble(sex = rep(c("m", "m", "m", "m", "m", "m", "f", "f", "f", "f"), length.out = n), year = rep(c(2, 3, 4), length.out = n))
c = tibble(sex = rep(c("m", "m", "m", "m", "m", "f", "f", "f", "f", "f"), length.out = n), year = rep(c(1, 2, 3), length.out = n))
d = tibble(sex = rep(c("m", "m", "m", "m", "f", "f", "f", "f", "f", "f"), length.out = n), year = rep(c(0, 1, 2), length.out = n))
e = rbind(a, b)
f = rbind(e, c)
df = rbind(f, d)
df = df %>% mutate(sex = as.factor(sex))
df %>% ggplot(aes(year, fill = sex)) + geom_bar(position = "fill") + ylab("proportion") + scale_fill_manual(values = c("red", "skyblue"))

Model and pp_check

m = brm(sex ~ year, family = "bernoulli", data = df)

m %>% pp_check(type = c("bars"))

1 Like

The pp_check() function in the brms package is just a ggplot object, so you can do anything that you would normally do in ggplot:

pp_check(m) +
   geom_point(size = 2)

I don’t actually know that the geom_point option there will do what you want it to, but that’s at least the general idea of how to edit the posterior predictive check plot


Beyond manipulating the resulting ggplot object, as @wgoette correctly suggests, note that pp_check delegates to the ppc_XXX functions in bayesplot which have a bunch of ways to get customized. In your case, the size and fatten parameters should be helpful: PPCs for discrete outcomes — PPC-discrete • bayesplot

Best of luck with your visuals!