[ x] a suggested code or documentation change, improvement to the code, or feature request
The plot function does not currently produce a legend. This makes marginal prediction plots uninterpretable because the meaning of the different lines is not communicated in the plot.
Put your code here:
## load package
library("margins")
## code goes here
library(carData)
data(Prestige)
womenValues <- c(0, 25, 50, 75, 97.51)
m5 <- lm(income ~ education*women, data = Prestige)
mar5 <- margins(m5, variables = "education",
at = list(women = womenValues))
# There seems to be a bug in margins. We will apply a workaround until it is
# fixed https://github.com/leeper/margins/issues/147
attr(mar5, "at") <- select(attr(mar5, "at"),-index)
plot(mar5)
# Legend should be included
legend("topright",legend = womenValues,
lwd = seq(2, 0.25, length.out = 5),
title = "Share of women")```
Please specify whether your issue is about:
The plot function does not currently produce a legend. This makes marginal prediction plots uninterpretable because the meaning of the different lines is not communicated in the plot.
Put your code here: