/*********************************************************************************** *********************************************************************************** Replication of empirical results in Chapter 11: Causal Heterogeneity and Context Conditionality of Eric Neumayer and Thomas Plümper: Robustness Tests for Quantitative Research, Cambridge University Press 2017 *********************************************************************************** ***********************************************************************************/ * Stata version 12 or higher needed version 12 *********************************************************************************** *********************************************************************************** * change relative path to the directory where the data are located local DIR = "C:\Users\Eric\Documents\Book\Robustness\" cd "`DIR'" *********************************************************************************** *********************************************************************************** * Install user-written ado-files capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o) *********************************************************************************** *********************************************************************************** *** Split Sample Test * Baseline use "Chapter_11_heterogeneity.dta", clear set level 95 nbreg sumuskilled lnpopterr lndistance lngdppcconstterrorists polity2terrorists usmilpers_milperscomb if countrytarget=="United States" & countryallterrorists!="United States", nolrtest level(90) cluster( countryallterrorists) scalar coeff_b=_b[usmilpers_milperscomb] scalar se_b=_se[usmilpers_milperscomb] scalar lb_b= coeff_b -invnormal(1-(100-c(level))/200)*se_b scalar ub_b= coeff_b +invnormal(1-(100-c(level))/200)*se_b keep if e(sample) capture dropvars robustness* save "estimation sample", replace * Robustness test model capture program drop cdfsim program cdfsim version 12 drop _all use "estimation sample", replace capture drop select* gen select=runiform() capture drop select_dummy gen select_dummy=(select<.5) expand 2 nbreg sumuskilled lnpopterr lndistance lngdppcconstterrorists polity2terrorists usmilpers_milperscomb if select_dummy==0 & countrytarget=="United States" & countryallterrorists!="United States", nolrtest level(90) scalar se_bsim = _se[usmilpers_milperscomb] scalar coeff_bsim = _b[usmilpers_milperscomb] scalar z1_coeff_b = normal(-coeff_bsim/se_bsim) set level 95 scalar low_coeff_bsim = _b[usmilpers_milperscomb] - invnormal(1-(100-c(level))/200)*_se[usmilpers_milperscomb] scalar up_coeff_bsim = _b[usmilpers_milperscomb] + invnormal(1-(100-c(level))/200)*_se[usmilpers_milperscomb] scalar lb1=lb_b/se_bsim scalar ub1=ub_b/se_bsim scalar lb2=lb1-(coeff_bsim/se_bsim) scalar ub2=ub1-(coeff_bsim/se_bsim) scalar ubd=normal(ub2) scalar lbd=normal(lb2) scalar robustness1 = ubd-lbd nbreg sumuskilled lnpopterr lndistance lngdppcconstterrorists polity2terrorists usmilpers_milperscomb if select_dummy==1 & countrytarget=="United States" & countryallterrorists!="United States", nolrtest level(90) scalar se_bsim = _se[usmilpers_milperscomb] scalar coeff_bsim = _b[usmilpers_milperscomb] scalar z2_coeff_b = normal(-coeff_bsim/se_bsim) set level 95 scalar low_coeff_bsim = _b[usmilpers_milperscomb] - invnormal(1-(100-c(level))/200)*_se[usmilpers_milperscomb] scalar up_coeff_bsim = _b[usmilpers_milperscomb] + invnormal(1-(100-c(level))/200)*_se[usmilpers_milperscomb] scalar lb1=lb_b/se_bsim scalar ub1=ub_b/se_bsim scalar lb2=lb1-(coeff_bsim/se_bsim) scalar ub2=ub1-(coeff_bsim/se_bsim) scalar ubd=normal(ub2) scalar lbd=normal(lb2) scalar robustness2 = ubd-lbd end simulate rho1 = robustness1 rho2 = robustness2 coeff_bsim = coeff_bsim low_coeff_bsim = low_coeff_bsim up_coeff_bsim = up_coeff_bsim se_bsim = se_bsim zero1_coeff_b = z1_coeff_b zero2_coeff_b = z2_coeff_b, reps(1000) seed(3456223): cdfsim gen countzero_coeff_b = (low_coeff_bsim < 0) & (up_coeff_bsim > 0) describe summarize expand 2, gen(marker) gen rho=rho1 replace rho=rho2 if marker==0 _pctile rho, p(2.5, 97.5) matrix range_robustness = (r(r1),r(r2)) matrix rownames range_robustness = rho matrix colnames range_robustness = lower_025 upper_975 quietly summarize rho display "Estimated degree of effect robustness is: " r(mean) display "95% of unweighted simulated effect robustness ranges between: " matrix list range_robustness gen zero_coeff_b=zero1_coeff_b replace zero_coeff_b=zero2_coeff_b if marker==0 generate weight = 1 quietly summarize weight if rho < . replace weight = weight/r(sum) replace weight = 0 if rho == . gen wzero_coeff_b = zero_coeff_b*weight quietly summarize wzero_coeff_b scalar sumzero_coeff_b = r(sum) display "Cumulative density of simulated coefficients smaller zero: " sumzero_coeff_b *********************************************************************************** *********************************************************************************** *** Group-specific Effect Test * Baseline use "Chapter_11_heterogeneity.dta", clear set level 95 quietly nbreg sumuskilled lnpopterr lndistance lngdppcconstterrorists polity2terrorists usmilpers_milperscomb if countrytarget=="United States" & countryallterrorists!="United States", nolrtest level(90) cluster( countryallterrorists) scalar coeff_b=_b[usmilpers_milperscomb] scalar se_b=_se[usmilpers_milperscomb] scalar lb_b= coeff_b -invnormal(1-(100-c(level))/200)*se_b scalar ub_b= coeff_b +invnormal(1-(100-c(level))/200)*se_b * Robustness test model capture drop incgroups gen incgroups=. replace incgroups=1 if inc_low==1 replace incgroups=2 if inc_low_mid==1 replace incgroups=3 if inc_up_mid==1 replace incgroups=4 if inc_high==1 replace incgroups=5 if inc_high_oecd==1 nbreg sumuskilled lnpopterr lndistance lngdppcconstterrorists polity2terrorists i.incgroups#c.usmilpers_milperscomb if countrytarget=="United States" & countryallterrorists!="United States", nolrtest level(90) cluster( countryallterrorists) outreg2 using table, replace excel * Estimating degrees of effect robustness forvalues i = 1(1) 5 { scalar coeff_r=_b[`i'.incgroups#c.usmilpers_milperscomb] scalar se_r=_se[`i'.incgroups#c.usmilpers_milperscomb] scalar lb1=lb_b/se_r scalar ub1=ub_b/se_r scalar lb2=lb1-(coeff_r/se_r) scalar ub2=ub1-(coeff_r/se_r) scalar ubd=normal(ub2) scalar lbd=normal(lb2) scalar robustness=ubd-lbd di "Degree of effect robustness for income group `i' is " di robustness } *********************************************************************************** *********************************************************************************** *** Chow Test of Group Heterogeneity * Baseline use "Chapter_11_heterogeneity.dta", clear set level 95 quietly nbreg sumuskilled lnpopterr lndistance lngdppcconstterrorists polity2terrorists usmilpers_milperscomb if countrytarget=="United States" & countryallterrorists!="United States", nolrtest level(90) cluster( countryallterrorists) scalar coeff_b=_b[usmilpers_milperscomb] scalar se_b=_se[usmilpers_milperscomb] scalar lb_b= coeff_b -invnormal(1-(100-c(level))/200)*se_b scalar ub_b= coeff_b +invnormal(1-(100-c(level))/200)*se_b * Robustness test model capture drop islam_majority gen islam_majority=0 replace islam_majority=1 if (muslim>=50 & muslim<.) nbreg sumuskilled lnpopterr lndistance lngdppcconstterrorists polity2terrorists i.islam_majority i.islam_majority#c.usmilpers_milperscomb if countrytarget=="United States" & countryallterrorists!="United States", nolrtest level(90) cluster( countryallterrorists) outreg2 using table, append excel * Estimating degrees of effect robustness scalar coeff_r=_b[0.islam_majority#c.usmilpers_milperscomb] scalar se_r=_se[0.islam_majority#c.usmilpers_milperscomb] scalar lb1=lb_b/se_r scalar ub1=ub_b/se_r scalar lb2=lb1-(coeff_r/se_r) scalar ub2=ub1-(coeff_r/se_r) scalar ubd=normal(ub2) scalar lbd=normal(lb2) scalar robustness=ubd-lbd di "Estimated degree of effect robustness in non-Muslim countries is: " robustness quietly nbreg sumuskilled lnpopterr lndistance lngdppcconstterrorists polity2terrorists i.islam_majority i.islam_majority#c.usmilpers_milperscomb if countrytarget=="United States" & countryallterrorists!="United States", nolrtest level(90) cluster( countryallterrorists) scalar coeff_r=_b[1.islam_majority#c.usmilpers_milperscomb] scalar se_r=_se[1.islam_majority#c.usmilpers_milperscomb] scalar lb1=lb_b/se_r scalar ub1=ub_b/se_r scalar lb2=lb1-(coeff_r/se_r) scalar ub2=ub1-(coeff_r/se_r) scalar ubd=normal(ub2) scalar lbd=normal(lb2) scalar robustness=ubd-lbd di "Estimated degree of effect robustness in Muslim countries is: " robustness *********************************************************************************** *********************************************************************************** *** Conditionality Test * Baseline model use "Chapter_11_heterogeneity_2.dta", clear set level 95 xi: reg lntrafvolumemill_av lnmigrantstock lngdppcconst_sumboth lntrade lnfdi lnvisitors contiguity4dummy comlang lndistance coloniallinkplusrussia lnpop_sumboth lnpop_sumboth_sq i.reporter*i.year i.partner*i.year if year>2000, robust cluster(dyadid) outreg2 using table1, replace excel level(95) e(rmse) margins, dydx(lnmigrantstock) at(lngdppcconst_sumboth=(6(.1)11.5)) saving(margins_base, replace) capture drop coeff_b capture drop se_b predictnl coeff_b=((_b[lnmigrantstock]*lnmigrantstock)), se(se_b) * Robustness test model xi: reg lntrafvolumemill_av c.lnmigrantstock##c.lngdppcconst_sumboth lntrade lnfdi lnvisitors contiguity4dummy comlang lndistance coloniallinkplusrussia lnpop_sumboth lnpop_sumboth_sq i.reporter*i.year i.partner*i.year if year>2000, robust cluster(dyadid) capture drop coeff_r capture drop se_r predictnl coeff_r=((_b[c.lnmigrantstock*c.lngdppcconst_sumboth]*lnmigrantstock*lngdppcconst_sumboth+_b[lnmigrantstock]*lnmigrantstock)), se(se_r) outreg2 using table1, append excel level(95) e(rmse) margins, dydx(lnmigrantstock) at(lngdppcconst_sumboth=(6(.1)11.5)) saving(margins_rob, replace) combomarginsplot margins_base margins_rob, labels("Baseline" "Robustness test") title("") ytitle("") xtitle("Log of dyadic sum of GDP p.c.") graphregion(color(white)) bgcolor(white) graph save "Conditionality test", replace graph export "Conditionality test.eps", as(eps) replace *** Non-linear Conditionality Test * Baseline model use "Chapter_11_heterogeneity_2.dta", clear set level 95 xi: reg lntrafvolumemill_av c.lnmigrantstock##c.lngdppcconst_sumboth lntrade lnfdi lnvisitors contiguity4dummy comlang lndistance coloniallinkplusrussia lnpop_sumboth lnpop_sumboth_sq i.reporter*i.year i.partner*i.year if year>2000, robust cluster(dyadid) margins, dydx(lnmigrantstock) at(lngdppcconst_sumboth=(6(.1)11.5)) saving(margins_base, replace) capture drop coeff_b capture drop se_b predictnl coeff_b=((_b[c.lnmigrantstock*c.lngdppcconst_sumboth]*lnmigrantstock*lngdppcconst_sumboth+_b[lnmigrantstock]*lnmigrantstock)), se(se_b) * Robustness test model xi: reg lntrafvolumemill_av c.lnmigrantstock##c.lnmigrantstock##c.lngdppcconst_sumboth##c.lngdppcconst_sumboth lntrade lnfdi lnvisitors contiguity4dummy comlang lndistance coloniallinkplusrussia lnpop_sumboth lnpop_sumboth_sq i.reporter*i.year i.partner*i.year if year>2000, robust cluster(dyadid) capture drop coeff_r capture drop se_r predictnl coeff_r=((_b[c.lnmigrantstock*c.lngdppcconst_sumboth]*lnmigrantstock*lngdppcconst_sumboth+_b[lnmigrantstock]*lnmigrantstock+_b[c.lnmigrantstock*c.lnmigrantstock]*lnmigrantstock*lnmigrantstock+_b[c.lnmigrantstock*c.lnmigrantstock*c.lngdppcconst_sumboth]*lnmigrantstock*lnmigrantstock*lngdppcconst_sumboth+_b[c.lnmigrantstock*c.lngdppcconst_sumboth*c.lngdppcconst_sumboth]*lnmigrantstock*lngdppcconst_sumboth*lngdppcconst_sumboth+_b[c.lnmigrantstock*c.lnmigrantstock*c.lngdppcconst_sumboth*c.lngdppcconst_sumboth]*lnmigrantstock*lnmigrantstock*lngdppcconst_sumboth*lngdppcconst_sumboth)), se(se_r) outreg2 using table1, append excel level(95) e(rmse) margins, dydx(lnmigrantstock) at(lngdppcconst_sumboth=(6(.1)11.5)) saving(margins_rob, replace) combomarginsplot margins_base margins_rob, labels("Baseline" "Robustness test") title("") ytitle("") xtitle("Log of dyadic sum of GDP p.c.") graphregion(color(white)) bgcolor(white) graph save "Non-linear conditionality test", replace graph export "Non-lienar conditionality test.eps", as(eps) replace