如何改进我的交互模型的情节

问题描述 投票:0回答:1

对于一篇论文,我想包含一张交互效果图。我不确定是否以及如何改进它以使我的交互效果更加明显。这是 R 代码:

plot_model4 <- plot_model(model4, type = "int", 
               terms = c("log_EU_immigration_cumulative_4yr", "lknemny"), 
               ci.lvl = 0.95) +  labs(
title = "Predicted Welfare State Support Based on Exposure to EU Immigration and Individual Financial Insecurity",
x = "Cumulative EU Immigration (Log, Last 4 Years)",
y = "Predicted Support for Welfare State",
color = "Financial Insecurity Likelihood: How likely not enough money for household necessities next 12 months") + scale_color_manual(
values = c("#984464", "#BFA5A3", "#449777", "#A4D8A0"), 
labels = c("Not at all likely", "Not very likely", "Likely", "Very likely")) + theme_minimal() + theme(legend.position = "right") + scale_x_continuous(breaks = scales::pretty_breaks(n = 10)) + scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) 

Plot

r plot rstudio interaction
1个回答
0
投票

不幸的是,我不知道如何用

plot_model()
实现这一点。但这里有一个替代库的示例:
marginaleffects
。也许这对您或其他读者有用。

marginaleffects
网站包含大量详细教程。这些在这种情况下可能特别有用:

在下面的第一张图中,我们显示了所有类别。在第二张图中,我们使用

list()
来指定要显示的
carb
主持人的哪些值:

library(marginaleffects)
mod <- lm(mpg ~ wt * factor(carb), data = mtcars)

plot_predictions(mod, condition = c("wt", "carb"))

plot_predictions(mod, condition = list("wt", "carb" = c(1, 8)))

© www.soinside.com 2019 - 2024. All rights reserved.