Contrast coding with brms

It seems that brm() adopts the the default settings in R: factors (categorical variables) are dummy-coded with 0/1. If I want to switch to deviation coding (-1, 0, and 1), would adding the following line in R work?

options(contrasts = c(“contr.sum”, “contr.poly”))

Thanks!

1 Like

That would work.

1 Like

Hi, when I try this [or in my case, options(contrasts = c(‘contr.bayes’, ‘contr.poly’)) ] the labels for my levels for each condition get replaced with “Condition1,2,3…”, and I have no way of knowing which comparisons are being run. Is there any way to retain the naming scheme from my dataframe?

The naming of the factor levels is by the R, not brms, convention. With deviation coding for a factor in R, the levels of the factor are by default set alphabetically with the last one as the reference/base. So, in the output, Condition1 would be the contrast between the first level relative to the last one, and similarly for the rest.