Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: logit average "marginal" effect of dummy variable with predict


From   Richard Williams <richardwilliams.ndu@gmail.com>
To   statalist@hsphsun2.harvard.edu, statalist@hsphsun2.harvard.edu
Subject   Re: st: logit average "marginal" effect of dummy variable with predict
Date   Tue, 07 May 2013 08:32:03 -0400

You are treating smoke as a continuous variable rather than as discrete. Instead do

logit low lwt ptd i.smoke age
margins, dydx(smoke) //AME of smoke

The latter produces

Average marginal effects                          Number of obs   =        112
Model VCE    : OIM

Expression   : Pr(low), predict()
dy/dx w.r.t. : 1.smoke

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     1.smoke |    .229702   .0923031     2.49   0.013     .0487913    .4106127
------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.


Incidentally, I like this alternate syntax, mostly because of the way output gets labeled, especially in graphs:

margins r.smoke

At 07:48 AM 5/7/2013, Chris wrote:
Dear statalist,

I want to compute the average marginal effect of an interaction
effect, so I have to simultaneously "switch on and off" two treatment
dummies (one treatment dummy, and one subgroup dummy interacted with
the treatment dummy). Margins can't do that, as Richard Williams
recently pointed out here on statalist.
(http://www.stata.com/statalist/archive/2013-01/msg00263.html)

So I am trying to compute it manually. However, I don't even manage to
compute the average marginal effect with the predict command; somehow,
there is a discrepancy between margins and predict even for simple
cases. Does anybody know why? Example:

-------------------------------
webuse lowbirth, clear
logit low lwt ptd smoke age
margins, dydx(smoke) //AME of smoke

replace smoke=1 //set entire sample smoke=1
predict withsmoke //predict probability
replace smoke=0 //set entire sample smoke=0
predict withoutsmoke //predict probability
gen me=withsmoke-withoutsmoke //compute discrete "marginal" effect
egen ame=mean(me) //AME of smoke
-------------------------------

The margins command gives an AME of .2198375, while the predict
version gives .2297. Which is right and why do they differ?

Thanks!
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu
WWW:    http://www.nd.edu/~rwilliam

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index