1
$\begingroup$

I'm having trouble in understanding the predictive margins after a log linear regression with endogenous treatment effects.

Using stata (with weighted survey design) I ran the following, where logwage is the log of wage. The log was taken because wage was not normally distributed. There is also information about the workers' demographics such as racial/ethnic, gender, previously held education, and whether or not they participated in a voluntary training (binary variable yes = 1, no = 0).

svy: etregress logwage i.race gender, treat(training = i.education gender) 

--------------------------------------------------------------------------------------------------
                                 |             Linearized
                                 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
---------------------------------+----------------------------------------------------------------
logwage                          |
                            race |
                African American |   .3891554   .0031105    12.20   0.000     .2000000    .8474752
                 Asian American  |   .1487310   .0002843    04.11   0.000     .027113     .8765290
                                 |
                          gender |
                         female  |  -.0230411    .010445    -6.85   0.000    -.115341   -.0107295
                                 |


                      1.training |   .3703371   .0451778    10.61   0.000     .2018037    .4186134
  

  ---------------------------------+----------------------------------------------------------------
    training                         |
                         i.education |
                         Highschool  |  -.0715731   .0490565     1.28   0.098    -.1106579    .1291781
                            College  |   .1271380   .0401052     3.95   0.003     .0329516    .2107563
                        Grad School  |   .8522143   .0085337     8.99   0.000     .8271381    .9573284
                                     |
                              gender |
                             female  |   .0127444   .0100058     5.33   0.041     .0100558    .0866312
                               _cons |  -1.260083   .0327235   -26.12   0.000    -1.531405   -1.098524
    ---------------------------------+----------------------------------------------------------------


                             /athrho |   .0051552    .031410     0.17   0.827    -.0722533    .0810246
                            /lnsigma |  -1.872551   .0166818   -73.50   0.000    -1.928624   -1.278064
    ---------------------------------+----------------------------------------------------------------
                                 rho |   .0084120   .0421116                     -.0649947    .0888529
                               sigma |   .4000831   .0038170                      .1925127    .5067780
                              lambda |   .0012673   .0226365                     -.0324029 

after this, margins calculated (as directed by Stata's marginal analysis page here)

 margins

Predictive margins


Expression   : Linear prediction, predict()

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   4.810383   .0072197   666.28   0.000      4.79622    4.824546
------------------------------------------------------------------------------

and

margins i.gender 

Predictive margins

Expression   : Linear prediction, predict()

--------------------------------------------------------------------------------------------
                           |            Delta-method
                           |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
---------------------------+----------------------------------------------------------------
                    Gender |
                   Female  |   4.305098   .0097962   439.47   0.000     4.285881    4.324314
                     Male  |   4.523071   .0077528   583.41   0.000     4.507863     4.53828

Now there is a Stata help page here that implies log costs can be changed in the margin computation to be expected average wage. However, when this is run there is an error:

margins, expression(exp(predict(eta))*(exp((_b[/var(logwage)])/2)))
option eta not allowed
r(198);

How to interpret the marginal _cons and female then given the log of wage was used as the dependent variable here?

$\endgroup$

1 Answer 1

2
$\begingroup$

You are not using gsem, so you don't have an eta. So let's step back and think about what you are trying to do.

You have $E[\ln y|x]$, but you want to calculate $E[y|x]$. Exponentiating the predicted values from the log model will not provide unbiased estimates of $E[y|x]$, as $$E[y_i|x_i] = \exp(x_i'\beta) \cdot E[\exp(u_i)].$$

If $u \stackrel{iid}{\sim} N[0,\sigma^2]$, then $E[\exp(u)] = \exp(0.5 \cdot \sigma^2)$. That quantity may be estimated by replacing $\sigma^2$ with its consistent estimate $s^2$. You have that from etregress and you also have its variance, so you should be good.

I believe the first one below is the equivalent of what you want:

. webuse nhanes2f, clear

. qui svyset psuid [pweight=finalwgt], strata(stratid)

. qui svy: etregress loglead i.female i.diabetes, treat(diabetes = weight age height i.female) // coefl

. margins, expression(exp(predict(xb))*exp((exp(_b[/:lnsigma]))^2/2))

Predictive margins

Number of strata   =        31                 Number of obs     =       4,940
Number of PSUs     =        62                 Population size   =  56,316,764
Model VCE    : Linearized                      Design df         =          31

Expression   : exp(predict(xb))*exp((exp(_b[/:lnsigma]))^2/2)

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   14.39444   .2534461    56.79   0.000     13.87753    14.91134
------------------------------------------------------------------------------

. di "E[exp(u)] = " exp((exp(_b[/:lnsigma]))^2/2)
E[exp(u)] = 1.073898

. sum lead

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
        lead |      4,942    14.32032    6.167695          2         80

This makes strong assumptions.

You can also try using another version of the correction that makes fewer distributional assumptions (just homoscedastic iid). Here it really makes no difference:

. /* This assumes homoscedastic iid errors (Duan's "smearing" re-transformation) */
. predict double ln_yhat, xb
(2 missing values generated)

. gen double expuhat = exp(ln_yhat - loglead) 
(5,397 missing values generated)

. quietly sum expuhat

. di "E[exp(u)] = " r(mean)
E[exp(u)] = 1.0780898

. gen double yhat_duan = exp(ln_yhat)*r(mean)
(2 missing values generated)

. sum lead yhat_duan if e(sample)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
        lead |      4,940    14.32287    6.167599          2         80
   yhat_duan |      4,940    14.48996    2.728553   11.81736    21.2051

The actual mean is \$14.32, Duan's method gives you \$14.49 and the original method gives you \$14.39.

It might make sense to take two (or more) averages: one for the treated observations and one for untreated if you have reasons to believe there's heteroskedasticity across the two groups, but homoskedasticity within them. You could also go it by gender, etc. This lets you relax homoskedasticity assumption a bit.

Unfortunately, I don't know of a way to do this with margins that takes the variance from the estimation of the residuals into account.

Usually this kind of re-transformation adjustments makes the predictions line up better on average, but it does not ensure that predictions for individual cases are particularly good. You can see evidence of that in the range (or if you plot a histogram of the actuals and the predictions).

$\endgroup$
3
  • $\begingroup$ To clarify then, rather than putting the margin calculation back into dollars is it better to keep it in the reported unit of the original post (mine above)? And if so, is the interpretation then 100*(exp(4.305098)-1) = 7307.64% change in wage associated with being female? (I know the value is odd, but I use random data for public example). If this yes, then is the _cons thought of as 100*(exp(4.810383)-1) = 12177.86% simply effect of being employed? $\endgroup$
    – iPlexipen
    Jul 29, 2020 at 1:17
  • 1
    $\begingroup$ You are mixing up predictions of mean wages in dollars with the changes in wages, calculated in percent. You are plugging a predicted wage for both men and women into a formula for calculating the marginal effect of female on wages in percent, in place of the female coefficient. I suggest that you ask a separate question where you ask "how do I calculate the marginal effect on y from an etregess model of ln(y)". $\endgroup$
    – dimitriy
    Jul 29, 2020 at 1:44
  • 1
    $\begingroup$ @Quixy I think I made an error in the first part, now fixed, I think. I was evaluating the e(sigma), which was effectively treating it as constant, rather than a random variable. Since Stata thinks in terms of ln(sigma), now there is an extra exp(). $\endgroup$
    – dimitriy
    Jul 29, 2020 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.