Plot interactions for family="categorical"

Please also provide the following information in addition to your question:

  • Operating System: Windows
  • brms Version: 2.9.0

I am trying to plot the interactions of a model with the following structure.

mod1 = brms::brm(Y ~ A*B+
                       C*B+ 
                       D + E+ F+
                       (1 |G) + (1|H),
                 control = list(adapt_delta = 0.99, max_treedepth = 10),
                 iter = 10000,
                 cores = 4,
                 data = dat6,
                 family="categorical")

the expression marginal_effects(mod1, categorical = T) gives me the following warning.

Warning message:
Interactions cannot be plotted directly if 'categorical' is TRUE. Please use argument 'conditions' instead. 

I am not sure how to set the conditions, but looking at examples in the help page I tried:

conditions <- data.frame(A = c(-1, 0, 1))
marginal_effects(mod1, effects  = "A:B",
                 conditions = conditions)

but I get the error

Error: Please set 'categorical' to TRUE.

Does anybody have an example to plot interactions in categorical models?
Thanks for any suggestion.

Can you try:

conditions <- data.frame(A = c(-1, 0, 1))
marginal_effects(
  mod1, 
  effects  = "B",
  conditions = conditions,
  categorical = TRUE
)

?

Some permutation of effects & conditions should work, but remember to set categorical = TRUE.

1 Like