Fitting brms model and represent graphily

I’m new to Bayesian models.
I trying to create a model with “brms” to compare micronucleus counts beetween exposed and not exposed to pesticides population. For now that’s my model:

brm1 ← brm(MN ~ exposion + age + gender + BMI + alcohol + smoking + physical activity + ethnicity,
data = data,
family = poisson(link = “log”), chains = 4, iter = 3000, warmup = 1000,
set_prior(“normal(0,2.5)”, class = “b”, coef = “age”),
set_prior(“normal(0,2.5)”, class = “b”, coef = “BMI”),
set_prior(“multinominal()”, class = “b”, coef = c(“alcohol”, “smoking”, “physical activity”, “ethnicity”)),
set_prior(“bernoulli(0,5)”, class = “b”, coef = c(“exposion”, “gender”)))

Ok, the model converges well apparently, with Rhat = 1.
But I’ve been having some trouble representing these results graphically.
First problem: When I access the results with Summary(brm1), some results of some variables are omitted, for example: In the variable exposure, I have two conditions “exposed” and “not exposed”, but the results just show the effect size for “not exposed”, the same occurs for “physical activity” where I have five different conditions.

Second problem: I not getting represent this results graphily. I thought in the forest plot to draw the effect sizes.

Well, if someone knows how i improve these and other points that I may be making mistakes, i thanks

Welcome to the Stan community, @Vitor_Girardi!

This is normal behavior, and doesn’t mean that your model is doing anything wrong. When you provide categorical predictors to a regression formula in brms, it will default to coding the first factor level in alphabetical order as the default/reference/intercept. (NB - This is the standard behavior for many R functions/packages.) You can set a different level to be the reference using relevel(my_factor, ref = "{desired reference level}"). As such, you’ll always see terms in the fitted model that omit one level of each categorical predictor. These apparently omitted levels aren’t left out of the model, instead they are fit as the (Intercept).

I suggest looking at the tidybayes package vignette for working with brms models. I think the ‘Posterior predictions’ subheading may have the kind of plot you’re looking for.

1 Like