# Conditional_effects: level over other fixed effects

Operating System: Windows 10 x64 (build 18363)
R Version: 3.6.1
brms Version: brms_2.11.1

Hi all,

sorry, I have a beginners question. I am running a multinomial (categorical) model, where a categorical decision is explained by three fixed effects (without interactions). I want to extract the conditional_effects of each fixed effect, while ignoring the effect of the other fixed effects.
It seems a very simple thing to do, but I can’t figure out how. I guess the answer lies in how I define the conditions argument in conditional_effects.

Here a little example simulation showing my problem. The left side (for factor “A”) of all the conditional_effects plots looks the same.

Greetings, Alex

``````library(brms)
set.seed(42)
#Sample fixed effects
resp2type<-data.frame(type1=sample(c("A","B"),200,replace=T),
type2=sample(c("A","B"),200,replace=T),
type3=sample(c("A","B"),200,replace=T))

#Calculate number of As and Bs per row
sumA<-rowSums(resp2type=="A")
sumB<-rowSums(resp2type=="B")

#Add response column, where probability of response depends somewhat on number of As and Bs
resp2type\$resp<-sapply(1:200,function(x) sample(c("r1","r2","r3"),
prob=0.5+c(sumA[x],sumA[x]+sumB[x],sumB[x]),
1,replace=T))

#Multinomial model
mod1<-brm(resp ~ type1 + type2 + type3, data = resp2type,
family="categorical",chains=3, iter=5000, warmup=2500)

#Conditional effects. The effects of "A" are the same for all three fixed effects!
conditional_effects(mod1,"type1",categorical=T)
conditional_effects(mod1,"type2",categorical=T)
conditional_effects(mod1,"type3",categorical=T)
``````

PS: If I run the following, I see that the left side in each plot is the result if type1, type2 and type3 are “A” (first factor of each column)

`conditional_effects(mod1,conditions=make_conditions(resp2type,vars=c("type2","type3")),"type1",categorical=T)`

I think I found the solution myself.
This forum entry here helped me:

I changed the global contrasts to
options(contrasts = c(“contr.sum”, “contr.poly”))
before running brm. Then, later in the conditional_effects, to look at e.g. the effect of type1 alone, I used:
conditional_effects(mod1, effects = “type1”, re_formula = NULL,categorical=T,conditions = data.frame(type2 = NA, type3= NA))

Now, the reference is not always the same and makes sense!

3 Likes