I've created a graph showing the interaction effect between "Disp" and "mpg" using the mtcars dataset. I want to change the default values of 106.78, 230.72, and 354.66 to show a line for other values, for example the minimum of 71.1, maximum of 472.0 and a middle value of maybe 258.0. I'd also like to manually select 2 or 4 values rather than the default of 3. All code is included below with some borrowed from other related questions about changing axes or legend labels but nothing about the graph itself.
data(mtcars)
interactionmodel <- brm(vs ~ 1 + mpg + disp + mpg:disp, data = mtcars, family = bernoulli())
conditional_effects(interactionmodel)
##Creating individual conditional effects plots
the_plotstest <- plot(conditional_effects(interactionmodel),
ask = FALSE)
#final plot
the_plotstest[['mpg:disp']] + ## if 'mpg:disp' is the conditional to show
theme_bw(base_size = 14) + ## e. g. an existing theme of choice
ylim(0, 1) +
labs(x = 'MPG',
y = 'VS')+
scale_color_discrete(name = "Disp") +
scale_fill_discrete(name = "Disp")
You could use the
plot_predictions()function from themarginaleffectspackage. The package website hosts over 25 vignettes with detailed tutorials and case studies. These two might be particularly useful:brms: https://marginaleffects.com/vignettes/brms.htmlDisclaimer: I am the
marginaleffectsmaintainer.