Statalist


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

Re: st: How does margins get semi-elasticity eydx here?


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: How does margins get semi-elasticity eydx here?
Date   Wed, 30 Dec 2009 23:16:07 -0500

Skipper Seabold <[email protected]> :
The -margins- manual entry is exhaustive and a good place to start,
but in short:
Don't divide by y but by yhat.  Particularly for a zero/one depvar,
where dividing by y just sets the negative outcomes to missing
(dividing by zero) and leaves the positives unchanged (dividing by
one).  Also no need to use Mata here...  and easier to see a mistake
in Stata probably.

clear all
use http://www.ats.ucla.edu/stat/stata/examples/greene/tbl19-1
qui logit grade gpa tuce psi
set type double
predict xb, xb
g f=invlogit(xb)/(1+exp(xb))
g fy=f/grade
predict p
g fp=f/p
su
mat b=r(mean)*e(b)
margins, eydx(*)
mat li b


On Wed, Dec 30, 2009 at 10:50 PM, Skipper Seabold <[email protected]> wrote:
> If eydx is defined as dy/dx * (1/y), then I don't understand how the
> following values are found by margins (using Stata 11):
>
> use http://www.ats.ucla.edu/stat/stata/examples/greene/tbl19-1, clear
> logit grade gpa tuce psi
>
> <snip>
>
> margins, eydx
>
> Average marginal effects                          Number of obs   =         32
> Model VCE    : OIM
>
> Expression   : Pr(grade), predict()
> ey/dx w.r.t. : gpa tuce 1.psi
>
> ------------------------------------------------------------------------------
>             |            Delta-method
>             |      ey/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>         gpa |   1.854637   .8479031     2.19   0.029     .1927771    3.516496
>        tuce |   .0624472   .0930901     0.67   0.502    -.1200061    .2449006
>       1.psi |   1.554903   .7283702     2.13   0.033      .127324    2.982483
> ------------------------------------------------------------------------------
>
>
> Presumably it would give something like the following, if I had
> treated psi as continuous (Please excuse the hackish mata.  I'm still
> learning my way around...).  Are the missing values (NaNs or Infs,
> depending on your take) handled in some odd way or is something
> entirely different going on?  I didn't see anything in the manual on
> this or with a (quick) google search.
>
> mata
> exog = st_data(., ("gpa", "tuce", "psi"))
> stata(". gen cons = 1")
> cons = st_data(., "cons")
> exog = (exog,cons)
> params = st_matrix("e(b)")'
> xb = exog * params
> pdf = exp(-xb):/(1:+exp(-xb)):^2
> dydx = pdf * params'
> endog = st_data(., ("grade"))
> mfx = mean(effects :/ endog)
> end
>
> Any clarifications or further references would be appreciated.
>
> Cheers,
> Skipper
>

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index