I am using Stata 14, and the command ivmediate.
This command is first used in: Dippel, C., Gold, R., Heblich, S., & Pinto, R. (2022). The effect of trade on workers and voters. The Economic Journal, 132(641), 199-217.
And it was first elaborated in: Dippel, C., Gold, R., Heblich, S., & Pinto, R. (2017). Instrumental variables and causal mechanisms: Unpacking the effect of trade on workers and voters (No. w23209). National Bureau of Economic Research.
This is what I am running:
ivmediate Y X1 X2 X3 X4, mediator(M) treatment(T) instrument(Z) vce(cluster X5) full
One of the outputs (and perhaps the most important one) is the % of the total effect of T on Y that passes through M.
Below is an extract of the dataset, followed by two examples.
I have two problems, and I cannot find their solution or at least their explanation.
cross posting from stackoverflow and crossvalidated
[/CODE]
I omit most output; the relevant one is this for REG1
I omit most output; the relevant one is this for REG2
This command is first used in: Dippel, C., Gold, R., Heblich, S., & Pinto, R. (2022). The effect of trade on workers and voters. The Economic Journal, 132(641), 199-217.
And it was first elaborated in: Dippel, C., Gold, R., Heblich, S., & Pinto, R. (2017). Instrumental variables and causal mechanisms: Unpacking the effect of trade on workers and voters (No. w23209). National Bureau of Economic Research.
This is what I am running:
ivmediate Y X1 X2 X3 X4, mediator(M) treatment(T) instrument(Z) vce(cluster X5) full
One of the outputs (and perhaps the most important one) is the % of the total effect of T on Y that passes through M.
Below is an extract of the dataset, followed by two examples.
I have two problems, and I cannot find their solution or at least their explanation.
- regardless of the mediator that I use, the result is always 0.38%
- this percentage is far from what I compute by "hand" (as explained in Section 3.2 of Dippel et al. (2022), the estimated indirect effect and the effect calculated effect should be the same, besides from rounding)
cross posting from stackoverflow and crossvalidated
Code:
* Donwload packages you need search ivmediate h ivmediate
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(smokeW ever_drunk centered_age) byte sex float both_parents byte(FAS1_D2 FAS1_D3) float(monthbirth2 wave) long countryno float(RAE_M class_zed) . . -2.45341 1 1 0 1 0 2018 40000 4 1903 . . -2.2034097 2 1 0 1 11 2018 40000 3 1995 0 0 -.7867431 1 1 0 0 0 2001 40000 4 2607 0 0 -1.036743 2 . 0 0 3 2001 40000 7 2633 0 0 1.5465902 2 1 0 1 1 2010 56001 1 4763 . . -2.2867432 1 1 0 1 1 2018 56002 1 5712 0 0 -1.8700764 2 1 0 0 8 2010 56002 8 5824 0 0 1.5465902 2 1 0 1 3 2006 56002 3 6647 0 0 .5465902 2 1 0 1 3 2010 56002 3 6741 0 0 -2.1200764 2 0 0 0 11 2001 56002 11 8155 0 0 1.963257 1 1 1 0 8 2006 100000 8 9402 0 1 1.8799236 2 1 0 0 10 2006 191000 7 14348 0 0 -.6200764 2 1 0 0 3 2010 191000 0 14377 . . -.12007643 1 1 0 0 10 2018 191000 7 14920 0 0 .29659024 2 1 0 0 3 2001 191000 0 15662 0 0 2.0465903 2 0 0 1 10 2010 203000 2 16422 . . -2.536743 1 1 0 0 4 2018 203000 8 16592 . . -2.2867432 2 1 1 0 1 2018 203000 5 16649 0 0 -1.6200764 1 1 0 1 5 2014 203000 9 16658 . . -.3700764 1 1 1 0 3 2018 203000 7 16863 1 1 1.713257 1 1 0 1 1 2014 203000 5 17159 0 1 1.963257 2 1 0 0 11 2001 203000 3 17363 0 0 .12992357 2 0 0 1 5 2006 208000 5 17554 0 0 -1.786743 1 1 1 0 4 2010 208000 4 17997 0 0 -.20340976 1 0 0 0 9 2006 208000 9 18166 0 0 -1.9534098 2 0 0 0 6 2006 208000 6 18238 0 0 .12992357 2 1 0 1 5 2014 208000 5 18350 0 0 -1.6200764 2 1 1 0 2 2014 208000 2 18385 . 0 -1.1200764 1 1 0 1 8 2006 233000 11 18833 0 0 -.3700764 1 1 1 0 11 2010 233000 2 19051 0 1 -2.2867432 1 1 0 1 7 2001 233000 10 20044 0 0 1.8799236 2 1 0 1 10 2014 246000 10 20454 0 . -2.1200764 2 1 0 1 9 2010 246000 9 20556 0 1 2.2132568 2 1 1 0 5 2010 246000 5 20952 0 1 1.963257 2 1 1 0 8 2006 246000 8 21023 0 0 -.0367431 1 1 0 1 8 2010 246000 8 21156 0 0 -1.786743 2 1 0 1 6 2001 246000 6 21168 . . -2.0367432 2 0 0 1 11 2018 250000 11 22222 . . -1.9534098 1 0 0 1 9 2018 250000 9 22471 . . -.5367431 2 0 0 0 4 2018 250000 4 22600 0 0 1.963257 1 1 0 1 9 2006 250000 9 22933 . . 1.3799236 2 1 0 0 5 2018 250000 5 23207 0 0 -2.786743 2 0 0 0 7 2001 250000 7 24005 . . .6299236 2 0 0 0 2 2018 300000 2 27513 0 0 .3799236 1 1 0 1 3 2010 300000 3 27625 0 0 .2132569 2 0 1 0 5 2010 348000 11 28850 0 . -1.7034098 1 1 0 0 5 2014 348000 11 28981 0 0 -2.0367432 2 1 0 0 9 2014 348000 3 29145 . . .29659024 1 1 0 1 6 2018 348000 0 29418 0 0 1.963257 1 1 0 1 9 2001 348000 3 29840 1 1 .5465902 2 1 1 0 0 2006 352000 0 31423 0 0 -1.536743 2 1 0 1 1 2006 352000 1 31474 0 0 .2132569 2 1 1 0 4 2006 352000 4 31736 0 0 2.3799236 1 0 0 1 2 2014 352000 2 31920 0 0 -2.2034097 2 0 0 0 1 2010 372000 1 33277 0 0 1.3799236 1 0 0 1 5 2014 380000 5 35811 0 1 -1.8700764 2 1 0 1 8 2006 380000 8 35812 0 0 1.8799236 1 1 0 1 6 2010 380000 6 35842 0 0 -2.0367432 1 0 1 0 7 2014 428000 7 38102 . . 2.3799236 1 1 0 1 1 2018 428000 1 38507 0 1 -.4534098 1 1 0 1 1 2010 440000 1 39537 0 1 1.6299236 1 1 0 0 0 2006 440000 0 39541 1 1 2.2965903 1 1 0 1 4 2010 440000 4 39681 0 0 .2132569 2 1 0 1 5 2010 440000 5 39686 0 0 -2.3700764 2 1 0 1 3 2014 442000 7 40807 0 0 -2.536743 1 1 0 1 5 2014 442000 9 41185 0 0 -2.8700764 2 1 0 1 1 2010 528000 4 43253 . . .29659024 1 1 0 0 0 2018 528000 3 43771 0 1 1.963257 1 . 0 0 4 2001 528000 7 44565 0 0 .29659024 1 . 0 1 6 2014 578000 6 44829 0 0 2.1299236 1 . 0 1 7 2014 578000 7 44952 1 1 1.463257 2 0 0 1 11 2010 578000 11 45041 0 0 -.12007643 1 1 0 1 10 2006 616000 4 46956 0 0 1.463257 2 1 0 0 5 2010 703000 9 53032 0 0 1.963257 2 0 0 1 7 2006 705000 7 53958 1 1 1.8799236 2 0 0 0 8 2006 705000 8 54007 0 0 .4632569 1 1 0 1 1 2014 705000 1 54098 0 . -.20340976 2 1 0 1 0 2006 724000 0 55349 0 1 2.2132568 1 1 0 0 5 2010 724000 5 56480 0 0 -2.2034097 2 0 0 1 7 2010 752000 7 57474 0 0 -1.6200764 1 1 0 1 0 2010 752000 0 57657 0 0 -.3700764 2 1 1 0 10 2014 752000 10 57880 . . -.0367431 1 1 0 1 9 2018 804000 9 62431 0 1 2.54659 1 1 0 0 0 2006 804000 0 63471 0 0 -1.8700764 1 1 0 0 8 2006 807000 8 64927 0 0 -2.2867432 1 1 0 0 6 2010 807000 6 65219 0 . -.6200764 1 1 0 1 5 2014 807000 5 65591 . . .12992357 1 1 0 0 8 2018 807000 8 65809 0 0 -2.1200764 1 0 0 0 4 2010 826001 8 66162 0 0 -1.6200764 2 1 0 1 11 2006 826001 3 66624 0 0 .2132569 2 1 0 0 5 2001 826001 9 66973 0 0 .4632569 1 1 0 1 2 2001 826001 6 67152 0 0 .4632569 2 . 0 1 2 2014 826002 0 67380 0 1 2.1299236 1 1 0 1 5 2010 826002 3 67623 . . 2.54659 1 1 0 1 2 2018 826002 0 67728 0 0 -.6200764 2 1 1 0 1 2010 826002 11 67755 0 1 1.6299236 2 1 0 1 11 2006 826002 9 67919 0 0 -1.1200764 1 1 0 1 8 2010 826002 6 68137 0 0 -1.3700764 1 0 0 0 8 2010 826003 0 68690 0 0 .5465902 2 0 0 1 10 2010 826003 2 69241 end label values sex sex label def sex 1 "Boy", modify label def sex 2 "Girl", modify label values countryno countryno label def countryno 40000 "Austria", modify label def countryno 56001 "Belgium (Flemish)", modify label def countryno 56002 "Belgium (French)", modify label def countryno 100000 "Bulgaria", modify label def countryno 191000 "Croatia", modify label def countryno 203000 "Czech Republic", modify label def countryno 208000 "Denmark", modify label def countryno 233000 "Estonia", modify label def countryno 246000 "Finland", modify label def countryno 250000 "France", modify label def countryno 300000 "Greece", modify label def countryno 348000 "Hungary", modify label def countryno 352000 "Iceland", modify label def countryno 372000 "Ireland", modify label def countryno 380000 "Italy", modify label def countryno 428000 "Latvia", modify label def countryno 440000 "Lithuania", modify label def countryno 442000 "Luxembourg", modify label def countryno 528000 "Netherlands", modify label def countryno 578000 "Norway", modify label def countryno 616000 "Poland", modify label def countryno 703000 "Slovakia", modify label def countryno 705000 "Slovenia", modify label def countryno 724000 "Spain", modify label def countryno 752000 "Sweden", modify label def countryno 804000 "Ukraine", modify label def countryno 807000 "Macedonia", modify label def countryno 826001 "England", modify label def countryno 826002 "Scotland", modify label def countryno 826003 "Wales", modify label values RAE_M RAE_M label def RAE_M 0 "0.RA", modify label def RAE_M 1 "1.RA", modify label def RAE_M 2 "2.RA", modify label def RAE_M 3 "3.RA", modify label def RAE_M 4 "4.RA", modify label def RAE_M 5 "5.RA", modify label def RAE_M 6 "6.RA", modify label def RAE_M 7 "7.RA", modify label def RAE_M 8 "8.RA", modify label def RAE_M 9 "9.RA", modify label def RAE_M 10 "10.RA", modify label def RAE_M 11 "11.RA", modify
Code:
ivmediate smokeW centered_age centered_age sex both_parents FAS1_D2 FAS1_D3 i.monthbirth2 i.wave i.countryno, /// *REG1 mediator(percab) treatment(diff_12) instrument(RAE_M) vce(cluster class_zed) full ivmediate ever_drunk age centered_age sex both_parents FAS1_D2 FAS1_D3 i.monthbirth2 i.wave i.countryno, /// *REG2 mediator(wellbeing) treatment(diff_12) instrument(RAE_M) vce(cluster class_zed) full
Code:
Mediator percab explains 0.38% of the total effect.
Code:
Mediator wellbeing explains 0.38% of the total effect.
Comment