Reputation: 11
I have 2 approaches to calculate my marginal effects.
The first model is the following
model1 <-
feglm(
FTAs ~
log(dist) +
log(gdp_d) +
...,
family = binomial(link = "logit"),
data = data
)
And I calculate the marginal effects via
model1_marginaleffects <-
slopes(
model1
)
summary(model1_marginaleffects)
My second approach was the following which automatically calculates the marginal effects.
model2 <-
logitmfx(
FTAs ~
log(dist) +
log(gdp_d) +
data = data
)
print(logitmfx_model3)
Does anyone know where the difference is coming from? The signs (+/-) are the same but the values totally differ. Do the functions take another baseline to calculate the marginal effects. If yes, what is the difference?
I looked into the documentations: https://cran.r-project.org/web/packages/marginaleffects/marginaleffects.pdf as well as https://cran.r-project.org/web/packages/mfx/mfx.pdf, but I do not understand the difference.
Upvotes: 1
Views: 195
Reputation: 17823
I believe that marginaleffects
computes the "average marginal effect (or slope)", whereas logitmfx
computes the "marginal effect (or slope) at the mean".
Those are distinct quantities. Here is a nice tutorial: https://www.andrewheiss.com/blog/2022/05/20/marginalia/
Note that you can easily compute both quantities with the marginaleffects
package. The discrepancy you observe is simply because the defaults differ, and not because marginaleffects
is incapable of replicating logitmfx
.
Also, please consider that it is much easier to answer a question like this when it is accompanied by a minimal working example. See:
How to make a great R reproducible example
Upvotes: 2