Statalist


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

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


From   gjhxmu@sina.com
To   statalist<statalist@hsphsun2.harvard.edu>
Subject   st: how to get marginal effect when dependent variable has ln function?
Date   Tue, 23 Jun 2009 20:12:32 +0800

Thank you very much for all replies! I am sorry for my delayed reply.


Austin mentioned that "Each observation may have a different marginal effect of x1 on y". 

I doubt that and I calculate below:

Assuming one equation is lny=a0+a1x1+a2x2+a3x3+e

and all other indenpendent variables are unchanged, then

Δlny=bΔx1,Δlny=lny2-lny1 = ln(y2/y1)=ln(Δy+1)=bΔx1,Δy=exp(bΔx1)-1, %Δy=100*(y2-y1)/y1=100*( exp(bΔx1)-1).

So as long as x1 changes one unit, the change percent of y is constant, not vary with various levels of x1.


I found -glm- is helpful. Thank you!

However, why are the results of -reg- and -glm- different?


The result of -reg-:


reg lny x1,eform("x1")

Source | SS df MS Number of obs = 149
-------------+------------------------------ F( 1, 147) = 13.02
Model | 43.4816065 1 43.4816065 Prob > F = 0.0004
Residual | 491.039393 147 3.34040403 R-squared = 0.0813

-------------+------------------------------ Adj R-squared = 0.0751
Total | 534.520999 148 3.61162837 Root MSE = 1.8277

------------------------------------------------------------------------------
lny | x1 Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x1 | 1.287607 .0902158 3.61 0.000 1.121113 1.478828


The result of -glm-with option link:


. glm y x1, link(log)

Iteration 0: log likelihood = -2298.4836 
Iteration 1: log likelihood = -2253.0398 
Iteration 2: log likelihood = -2227.9831 
Iteration 3: log likelihood = -2227.9678 
Iteration 4: log likelihood = -2227.9678 

Generalized linear models No. of obs = 149
Optimization : ML Residual df = 147
Scale parameter = 5.77e+11
Deviance = 8.48306e+13 (1/df) Deviance = 5.77e+11
Pearson = 8.48306e+13 (1/df) Pearson = 5.77e+11

Variance function: V(u) = 1 [Gaussian]
Link function : g(u) = ln(u) [Log]

AIC = 29.93245
Log likelihood = -2227.967803 BIC = 8.48e+13

------------------------------------------------------------------------------
| OIM
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x1 | .1846949 .0662293 2.79 0.005 .0548878 .3145019
_cons | 12.68207 .2616964 48.46 0.000 12.16916 13.19499


The result of -glm- with option family:


. glm y x1, family(poisson)
note: y has noninteger values

Iteration 0: log likelihood = -57268851 
Iteration 1: log likelihood = -55358804 
Iteration 2: log likelihood = -55358404 
Iteration 3: log likelihood = -55358404 

Generalized linear models No. of obs = 149
Optimization : ML Residual df = 147
Scale parameter = 1
Deviance = 110714755.9 (1/df) Deviance = 753161.6
Pearson = 159601721.9 (1/df) Pearson = 1085726

Variance function: V(u) = u [Poisson]
Link function : g(u) = ln(u) [Log]

AIC = 743065.8
Log likelihood = -55358403.61 BIC = 1.11e+08

------------------------------------------------------------------------------
| OIM
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x1 | .1673077 .000054 3097.82 0.000 .1672018 .1674136
_cons | 12.73727 .0001869 68143.38 0.000 12.7369 12.7376



Please forgive my ignorance if any and thank you for any reply!


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/



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