[R] glm: calculating average marginal effects for dummies
E Hofstadler
e.hofstadler at gmail.com
Mon Mar 28 08:44:37 CEST 2011
Dear list,
My question to follow is not a pure R question but contains also a
more general statistical/econometrical part, but I was hoping that
perhaps someone knowledgable on this list could offer some help.
I have estimated a binary logistic regression model and would like to
calculate average marginal effects for certain predictors of interest.
The average marginal effect for a continuous variable cont has been
given as
AME_cont = 1/n * SUM(beta_{cont} * prob(Y)* 1-prob(Y))
This seems easy enough to calculate with R.
However, the predictors I'm interested in are dummy variables, not
continuous, and the following formula has been suggested for
estimating the average marginal effect for dummies:
AME_dummy = 1/n*SUM(prob(Y| dummy=1) - prob(Y|dummy=0))
So according to this formula, the dummy is set to one and then to zero
for each observation (with the rest of the variables set at their
observed values), and the difference in the predicted values are
averaged across all observations.
So here's my questions:
1. (R-part:) How can I calculate AME_dummy in R? While predict() gets
the fitted values for the actual observations, I'm not quite sure how
to get predictions for the "counterfactual" part in AME_dummy, i.e.
setting the dummy to one and then zero for each observation, while
keeping the rest of the variables in the model at their observed
values for each observation.
2. (Econometric part: ) Would it be ok to use the formula for the
AME_cont even though the variable in question is a dummy? I guess it
might be problematic, since the continuous formula is based on a
derivation and thus a marginal increase, whereas the dummy-formula
looks at the change from 1 to zero -- am I correct?
Cheers,
Esther
More information about the R-help
mailing list