Question about marginal effects: how to change handing of interactions


In brms, you can change the name of a parameter like below (taken from ?marginal_effects with some small changes).

int_conditions <- list(
zBase = setNames(c(-1, 1), c(“A”, “B”)))

And then you can plot the two-way interaction

marginal_effects(fit, effects = “Trt:zBase”,
int_conditions = int_conditions)

I wonder if you can change the names of both “Trt” and xBase" in the example above (assuming both are categorical variables but are sum coded before running brms)? e.g.,

int_conditions <- list(
zBase = setNames(c(-1, 1), c(“A”, “B”)),
list(Trt = setNames(c(-1, 1), c(“A”, “B”))) # this is not working

I have been looking for this type of question but cannot find any.

Any help would be really appreciated.

Thank you.

int_conditions is only ment to define the conditions of the second factor, not the first one. If you only want to show subsets of the factor levels on the x-axis, you may need to create the predictions yourself using fitted or predict and then create the plot via the ggplot2 package.