Statalist


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

AW: st: how to get marginal effect when dependent variable has ln function?


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: how to get marginal effect when dependent variable has ln function?
Date   Sun, 21 Jun 2009 17:17:13 +0200

<> 

"(see also help for -ivpois- on SSC)"



Pages 22 ff. of http://www.stata.com/meeting/snasug08/nichols_gmm.pdf
may also help...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Austin Nichols
Gesendet: Sonntag, 21. Juni 2009 17:11
An: [email protected]
Betreff: Re: st: how to get marginal effect when dependent variable has ln
function?

Rose <[email protected]>:
It's not entirely clear what you want.  Each observation may have a
different marginal effect of x1 on y; did you want the marginal effect
of x1 on mean y at various levels of x, or the mean marginal effect of
x1 on y, or something else?  An easier way to proceed is to recognize
that a Poisson regression of y on x is much like a regression of lny
on x (see also help for -ivpois- on SSC or use -glm- with a log link),
and -mfx- after -poisson- gives you an estimate of mean dy/dx (sort
of) by default.  The answer you get by calculating the mean marginal
effect of x on y after regress lny x should be similar to a
Poisson-based answer--assuming no interactions, just calculate the
sample mean of the coef times the untransformed depvar (but note that
the dydx you calculate may be skewed etc and the mean dydx may not be
a good way to characterize the typical marginal effect or the range of
marginal effects, which may be better characterized via a graph of
some kind):

clear
sysuse auto
g lny=ln(mpg)
g x=weight/1000
poisson mpg x, r
mfx
reg lny x, r
g dydx=_b[x]*mpg if e(sample)
su dydx
sc dydx x
sc dydx mpg, name(vsy)

If you have interactions on the RHS, it becomes trickier, since -mfx-
does not produce the right results, but you can still use calculus:
dy/dx is y times d(lny)/dx so if you have
reg lny x xz z
then
g dydx=y*(_b[x]+_b[xz]*z) if e(sample)
su dydx

2009/6/21 <[email protected]>
>
> Dear statalists,
> I have an equation below:
> lny=a0+a1*x1+a2*x2+e
>
> and I typed below in the stata:
>
> g lny=ln(y)
> reg lny x1 x2
>
> However, how can I get the marginal effect of x1 on y?
>
> Thank you a lot!
>
> Sincerely,
> from Rose
*
*   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/


*
*   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