Extracting an effect with dummy coding

Hi Guys,

I have a logistic regression model and one of the predictors (X1) is a factor with three levels (baseline, treatment1, treatment2). brms gives two separate posteriors according to a dummy coding of baseline vs treatment1 and baseline vs. treatment2.

How can I check the main effect of X1? I thought of doing model comparison (with/without X1) but I was wondering if there is any straightforward way to have a posterior for X1 main effect (if this even makes sense…).


It’s not entirely clear to me what you mean by “main effect” here. If you mean the average effect of treatment (i.e., the average of the effect of treatment1 and treatment2), you can use the hypothesis function in brms. It would look something like:

hypothesis(fitted_mdl, "(treatment1 + treatment2) / 2 > 0")

where “treatment1” is the name of that effect as printed in the model summary, and the same for “treatment2”. This will summarise the average effect size and you can plot the hypothesis as well if wanted.

1 Like

My guess is that you want some kind of credible interval for whether X1 is a “significant” predictor, in the same way that a frequentist analysis can test a multi-level factor variable via an anova followed by post-hoc testing. The problem in a Bayesian context is that we don’t do null hypothesis significance testing. We see the probability of the effect of X1 being literally exactly zero as zero (unless we’re using a spike-and-slab prior, which isn’t advisable in general and may be impossible in Stan). To assess the strength of evidence for X1 “belonging” in the model, we can use model comparison approaches, as you say.

1 Like

Thank you both! Very helpfull.