R的边际效应(“边际”)

时间:2018-03-01 19:45:53

标签: r plot marginal-effects

我正在尝试绘制保证金命令(平均边际效应)的结果,并且图表上的变量顺序与标签的顺序不匹配(对于一个标签,我得到另一个变量的值)。对于ggplot,一切都很好(虽然它使用摘要)。任何人都可以解释发生了什么以及如何制作一个合适的情节?我很感激:)

library(ggplot2)
library(tibble)
library(broom)
library(margins)
library(Ecdat)

data(Participation)
?Participation
logit_participation = glm(lfp ~ ., data = Participation, family = "binomial")
tidy(logit_participation)
summary(logit_participation)

effects_logit_participation = margins(logit_participation)
print(effects_logit_participation)

summary(effects_logit_participation)
plot(effects_logit_participation)

effects_logit_participation = summary(effects_logit_participation)
ggplot(data = effects_logit_participation) +
  geom_point(aes(factor, AME)) +
  geom_errorbar(aes(x = factor, ymin = lower, ymax = upper)) +
  geom_hline(yintercept = 0) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45))

0 个答案:

没有答案