Hello,
My dependent variable is expressed as log(y + 1). This is done because some of my y values are equal to zero. My independent variables are raw scores. It is a panel dataset. I estimate the effects using fixed-effects OLS.
When only the dependent variable is log-transformed, we exponentiate the coefficient to obtain the multiplicative factor for every 1-unit increase in the independent variable x. This is clear.
However, what if I'm willing to understand the effect for a given value of x in the original units of y. Would this procedure be correct? I am using Stata's dataset as an example since I cannot share my data.
I understand that using expression(exp(xb()) - 1) under margins will make the conversion the original values of y, taking into account that 1 was added.
My dependent variable is expressed as log(y + 1). This is done because some of my y values are equal to zero. My independent variables are raw scores. It is a panel dataset. I estimate the effects using fixed-effects OLS.
When only the dependent variable is log-transformed, we exponentiate the coefficient to obtain the multiplicative factor for every 1-unit increase in the independent variable x. This is clear.
However, what if I'm willing to understand the effect for a given value of x in the original units of y. Would this procedure be correct? I am using Stata's dataset as an example since I cannot share my data.
I understand that using expression(exp(xb()) - 1) under margins will make the conversion the original values of y, taking into account that 1 was added.
Code:
. use https://www.stata-press.com/data/r18/nlswork.dta, clear
(National Longitudinal Survey of Young Women, 14-24 years old in 1968)
. * Converting log-transformed wage to its original units
. gen wage = exp(ln_wage)
. * Taking the natural log of wage plus 1
. gen ln_wage_plus1 = log(wage + 1)
. xtset idcode year
Panel variable: idcode (unbalanced)
Time variable: year, 68 to 88, but with gaps
Delta: 1 unit
. xtreg ln_wage_plus1 i.year tenure union wks_work, fe robust
Fixed-effects (within) regression Number of obs = 18,637
Group variable: idcode Number of groups = 4,112
R-squared: Obs per group:
Within = 0.1477 min = 1
Between = 0.2128 avg = 4.5
Overall = 0.1622 max = 12
F(14, 4111) = 99.93
corr(u_i, Xb) = 0.1698 Prob > F = 0.0000
(Std. err. adjusted for 4,112 clusters in idcode)
------------------------------------------------------------------------------
| Robust
ln_wage_pl~1 | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
year |
71 | .0267133 .0085263 3.13 0.002 .0099971 .0434296
72 | .0299803 .0098336 3.05 0.002 .010701 .0492595
73 | .0290363 .0107442 2.70 0.007 .0079719 .0501007
77 | .0623787 .011784 5.29 0.000 .0392757 .0854816
78 | .0832801 .0122998 6.77 0.000 .0591659 .1073943
80 | .0207636 .0132531 1.57 0.117 -.0052197 .0467468
82 | .0334551 .0133158 2.51 0.012 .007349 .0595612
83 | .1083472 .0133449 8.12 0.000 .082184 .1345104
85 | .0721576 .0142641 5.06 0.000 .0441922 .100123
87 | .086793 .0151642 5.72 0.000 .0570629 .116523
88 | .1494352 .0155955 9.58 0.000 .1188596 .1800109
|
tenure | .012772 .000996 12.82 0.000 .0108192 .0147248
union | .0782881 .0082139 9.53 0.000 .0621845 .0943917
wks_work | .0015437 .0001197 12.89 0.000 .001309 .0017784
_cons | 1.699111 .0113788 149.32 0.000 1.676802 1.721419
-------------+----------------------------------------------------------------
sigma_u | .33375129
sigma_e | .21308098
rho | .7104247 (fraction of variance due to u_i)
------------------------------------------------------------------------------
. summarize wks_work if e(sample)
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
wks_work | 18,637 63.2597 28.42125 0 104
. margins, at(wks_work = (0(10)100)) expression(exp(xb()) - 1)
Predictive margins Number of obs = 18,637
Model VCE: Robust
Expression: exp(xb()) - 1
1._at: wks_work = 0
2._at: wks_work = 10
3._at: wks_work = 20
4._at: wks_work = 30
5._at: wks_work = 40
6._at: wks_work = 50
7._at: wks_work = 60
8._at: wks_work = 70
9._at: wks_work = 80
10._at: wks_work = 90
11._at: wks_work = 100
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
_at |
1 | 5.282635 .047974 110.11 0.000 5.188608 5.376663
2 | 5.380371 .0410873 130.95 0.000 5.299841 5.460901
3 | 5.479627 .0339773 161.27 0.000 5.413033 5.546221
4 | 5.580427 .026641 209.47 0.000 5.528212 5.632642
5 | 5.682795 .0190793 297.85 0.000 5.645401 5.72019
6 | 5.786756 .0113115 511.58 0.000 5.764586 5.808926
7 | 5.892334 .0035904 1641.14 0.000 5.885297 5.899371
8 | 5.999554 .0055614 1078.78 0.000 5.988654 6.010454
9 | 6.108443 .0139617 437.51 0.000 6.081078 6.135807
10 | 6.219025 .0227721 273.10 0.000 6.174392 6.263657
11 | 6.331327 .0318807 198.59 0.000 6.268842 6.393812
------------------------------------------------------------------------------

Comment