2

I have a question similar to the one here: Testing the difference between marginal effects calculated across factors. I used the same code to generate average marginal effects for two groups. The difference is that I am running a logistic rather than linear regression model. My average marginal effects are on the probability scale, so emmeans will not provide the correct contrast. Does anyone have any suggestions for how to test whether there is a significant difference in the average marginal effects between group 1 and group 2?

Thank you so much, Ilana

IGR
  • 31
  • 1

1 Answers1

0

It is a bit unclear what the issue really is, but I'll try. I'm supposing your logistic regression model was fitted using, say, glm:

mod <- glm(cbind(heads, tails) ~ treat, data = mydata, family = binomial())

If you then do

emm <- emmeans(mod, "treat")
emm           ### marginal means
pairs(emm)    ### differences

Your results will be presented on the logit scale.

If you want them on the probability scale, you can do

summary(emm, type = "response")
summary(pairs(emm), type = "response")

However, the latter will back-transform the differences of logits, thereby producing odds ratios.

If you actually want differences of probabilities rather than ratios of odds, use regrid(), which will construct a new grid of values after back-transforming (and hence it will forget the log transformation):

pairs(regrid(emm))

It seems possible that two or more factors are present and you want contrasts of contrasts on the probability scale. In that case, extend this idea by calling regrid() on the table of EMMs to put everything on the probability scale, then follow the analogous procedure used in the linked article.

Russ Lenth
  • 5,922
  • 2
  • 13
  • 21