Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Question on mfx and regress

From   May Boggess <[email protected]>
To   [email protected]
Subject   Re: st: Question on mfx and regress
Date   06 Apr 2004 12:16:37 -0500

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

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

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

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

[email protected]

*   For searches and help try:

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