On Tuesday, Joao asked:
> Could any one help me understand why the coefficients of the natural log of
> a dependent variable are close, but not equivalent to the marginal effect of
> the same dependent variable estimated with the eydx option (dlogy/dx).
The short answer is because we are differentiating two different
functions.
Let's start with the semilog model. The linear predictor is the expected
value of the response E[ln(Y)]. Since this is a linear function of the
independent variables, the derivatives are just the coefficients of the
model. So, for example, the coefficient of x_i can be written
d(E[ln(Y)])/dx_i. --------------(1)
Note that this is a constant function of the independent variables,
meaning, we obtain the same answer regardless of where we evaluate the
function.
Now let's consider the partial elasticities of the linear model. This
time the linear predictor of the model is the expected value E[Y] and to
get the partial elasticity we take the log of this and then
differentiate:
d(ln(E[Y]))/dx_i. --------------(2)
So the difference between (1) and (2) is that E[ln(Y)] is not the same
function as ln(E[Y]).
We can calculate the partial elasticity (2) by hand easily. Writing f
for E[Y] and using the chain rule we obtain:
d(ln(f))/dx = d(ln(f))/df * df/dx,
and since f is the linear predictor,
d(ln(f))/dx = 1/f * b = b/f.
where b is the coefficient of x. Note that this is not a constant
function of the independent variables, because the linear predictor f
varies according to where I evaluate it.
Let's check all of this with an example:
clear
sysuse auto
replace wei=wei/1000
replace pri=pri/10000
replace len=len/100
regress price wei len
sum wei
scalar meanw=r(mean)
sum len
scalar meanl=r(mean)
scalar xb=meanw*_b[weight] + meanl*_b[length]+_b[_cons]
di "weight: eydx = " _b[weight]/xb
di "length: eydx = " _b[length]/xb
mfx, predict(xb) nose eydx
gen lnprice=ln(price)
regress lnprice wei len
We see that -mfx- agrees with our hand calculation of eydx. We could
verify that the partial elasticities are not a constant function of the
independent variables by using the option -at- on -mfx-.
We also see that the partial elasticities are not the same as the
coefficients of the semilog model, which is because taking logs,
estimating the model then differentiating, is not the same as estimating
the model, taking logs, then differentiating.
For those interested, there is an FAQ on the -mfx- option -eyex-:
http://www.stata.com/support/faqs/stat/mfx_eyex.html
--May
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/