使用plot_model在边际效应图中删除二进制预测变量
我正在尝试从logistic回归中产生边际效应图,我使用plot_model(sjplot)从可公开可用的调查数据中产生了边缘效应图。该情节的预测因子是二元(男性或女性),而响应变量是受访者是否投票给绿党。
这是代码:
logit3 %>%
plot_model(
type = "pred",
terms = "female"
) +
labs(
x = "Gender",
y = "Predicted probability of voting Green",
title = "Predicted probability of voting Green by gender"
)
这是图:
该情节可产生良好,而不是两者之间的线性线。
我敢肯定,这有一个简单的答案,我只是愚蠢,但我似乎找不到任何在线上的东西。我也没有在这个论坛上发布太多,所以请告诉我是否需要提供其他任何内容。
谢谢
I'm trying to produce a marginal effects plot from a logistic regression I ran, using plot_model (sjPlot), from publicly available survey data. The predictor for the plot is binary (male or female) and the response variable is whether a respondent votes for a Green party.
This is the code:
logit3 %>%
plot_model(
type = "pred",
terms = "female"
) +
labs(
x = "Gender",
y = "Predicted probability of voting Green",
title = "Predicted probability of voting Green by gender"
)
And this is the plot:
The plot produces fine but, since this is a binary predictor, I would like it as two separate points (for male and female), with confidence intervals, rather than than a linear line between the two.
I'm sure this has an easy answer and that I'm just being stupid, but I can't seem to find anything online. I also haven't posted much on this forum, so please let me know if I need to provide anything else.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,没有发布preprex。使用因子()指定预测变量解决了问题,谢谢!我以前曾尝试使用AS.Factor(),该factor()不起作用。
Sorry for not posting a reprex. Specifying the predictor using factor() solved the problem, thank you! I had previously tried using as.factor(), which didn't work.