[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Question on mfx and regress
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
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
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:
regress price wei len
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
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-:
* For searches and help try: