I am puzzled how Stata calculates the semi-elasticity in a n OLS model with a continuous outcome and a single binary regressor, y = a + b*x. The continuous case makes sense to me. The semi elasticity is (dy/dx)*(1/yhat) = b/yhat.
I thought that this would carry over to the discrete case with a finite difference instead of a derivative. In a linear model, the finite difference and the derivative should be the same, so this becomes (a + b*1 - a - b*0)/yhat = b/yhat . However, this does not seem to be the case:
Any guidance would be appreciated.
I thought that this would carry over to the discrete case with a finite difference instead of a derivative. In a linear model, the finite difference and the derivative should be the same, so this becomes (a + b*1 - a - b*0)/yhat = b/yhat . However, this does not seem to be the case:
Code:
. /* Continuous Case */ . sysuse auto, clear (1978 Automobile Data) . reg price c.mpg Source | SS df MS Number of obs = 74 -------------+---------------------------------- F(1, 72) = 20.26 Model | 139449474 1 139449474 Prob > F = 0.0000 Residual | 495615923 72 6883554.48 R-squared = 0.2196 -------------+---------------------------------- Adj R-squared = 0.2087 Total | 635065396 73 8699525.97 Root MSE = 2623.7 ------------------------------------------------------------------------------ price | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- mpg | -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879 _cons | 11253.06 1170.813 9.61 0.000 8919.088 13587.03 ------------------------------------------------------------------------------ . margins, eydx(mpg) Average marginal effects Number of obs = 74 Model VCE : OLS Expression : Linear prediction, predict() ey/dx w.r.t. : mpg ------------------------------------------------------------------------------ | Delta-method | ey/dx Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- mpg | -.0421593 .0123505 -3.41 0.001 -.0667795 -.017539 ------------------------------------------------------------------------------ . gen double eydx = _b[mpg]/(_b[_cons] + _b[mpg]*mpg) . sum eydx Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- eydx | 74 -.0421593 .0181532 -.1638066 -.0284862 . /* Binary Case */ . reg price i.foreign Source | SS df MS Number of obs = 74 -------------+---------------------------------- F(1, 72) = 0.17 Model | 1507382.66 1 1507382.66 Prob > F = 0.6802 Residual | 633558013 72 8799416.85 R-squared = 0.0024 -------------+---------------------------------- Adj R-squared = -0.0115 Total | 635065396 73 8699525.97 Root MSE = 2966.4 ------------------------------------------------------------------------------ price | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- foreign | Foreign | 312.2587 754.4488 0.41 0.680 -1191.708 1816.225 _cons | 6072.423 411.363 14.76 0.000 5252.386 6892.46 ------------------------------------------------------------------------------ . margins, eydx(foreign) Conditional marginal effects Number of obs = 74 Model VCE : OLS Expression : Linear prediction, predict() ey/dx w.r.t. : 1.foreign ------------------------------------------------------------------------------ | Delta-method | ey/dx Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- foreign | Foreign | .0501439 .1200041 0.42 0.677 -.1890798 .2893677 ------------------------------------------------------------------------------ Note: ey/dx for factor levels is the discrete change from the base level. . gen double eydx1 = _b[1.foreign]/(_b[_cons] + _b[1.foreign]*foreign) . gen double eydx2 = _b[1.foreign]/(_b[_cons] + _b[1.foreign]*0) . gen double eydx3 = _b[1.foreign]/(_b[_cons] + _b[1.foreign]*1) . gen double eydx4 = _b[1.foreign]/(_b[_cons] + _b[1.foreign]*.2972973) . sum eydx? Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- eydx1 | 74 .0506747 .0011573 .0489075 .0514224 eydx2 | 74 .0514224 0 .0514224 .0514224 eydx3 | 74 .0489075 0 .0489075 .0489075 eydx4 | 74 .0506481 0 .0506481 .0506481
Comment