See Bjarte Aagnes's solution from the following thread: https://www.statalist.org/forums/for...-with-coefplot
-
Login or Register
- Log in with
gen ll=-0.799 gen ul=-0.34 gen range = cond(_n==1, _n-.5, _n+.5) coefplot (sector1, aseq("Sector 1")) (sector2, aseq("Sector 2")) /// (sector3, aseq("Sector 3") ciopts(color(orange) recast(rcap)) mcolor(orange)) /// (sector4, aseq("Sector 4")) /// (sector5, aseq("Sector 5")) (sector6, aseq("Sector 6")) (sector7, aseq("Sector 7")) (sector8, aseq("Sector 8")) /// (sector9, aseq("Sector 9")) (sector10, aseq("Sector 10")) (sector11, aseq("Sector 11")) /// (sector12, aseq("Sector 12") ciopts(color(orange) recast(rcap)) mcolor(orange)) /// (sector13, aseq("Sector 13")) (sector14, aseq("Sector 14")) (sector15, aseq("Sector 15")) (sector16, aseq("Sector 16")) /// (sector17, aseq("Sector 17")) /// (sector18, aseq("Sector 18") ciopts(color(orange) recast(rcap)) mcolor(orange)) /// (sector19, aseq("Sector 19")) (sector20, aseq("Sector 20")) /// (sector21, aseq("Sector 21")) (sector22, aseq("Sector 22")) /// (sector23, aseq("Sector 23") ciopts(color(orange) recast(rcap)) mcolor(orange)), /// keep(lndistw) /// ciopts(recast(rcap) color(blue)) /// msymbol(O) mcolor(blue) /// ytitle("Coefficient of distance (log)") /// xtitle(" ") /// yline (-0.57, lcolor(red)) /// yline (0, lcolor(black)) /// xlabel( , angle(0) labsize(medium)) /// vertical aseq swapnames nokey /// level(90) /// xlab(1/23) xtitle("Sector") /// addplot(rarea ll ul range, color(gs8%40)) /// xlabel(1 "11" 2 "21", add custom labcolor(black) labsize(*0.64)) /// xlabel(3 "22", add custom labcolor(orange) labsize(*0.64)) /// xlabel(4 "23" 5 "31" 6 "32" 7 "33" 8 "42" 9 "44" 10 "45" 11 "48", add custom labcolor(black) labsize(*0.64)) /// xlabel(12 "49", add custom labcolor(orange) labsize(*0.64)) /// xlabel(13 "51" 14 "52" 15 "53" 16 "54" 17 "55", add custom labcolor(black) labsize(*0.64)) /// xlabel(18 "56", add custom labcolor(orange) labsize(*0.64)) /// xlabel(19 "61" 20 "62" 21 "71" 22 "72", add custom labcolor(black) labsize(*0.64)) /// xlabel(23 "81", add custom labcolor(orange) labsize(*0.64)) drop ll ul range
use "http://fmwww.bc.edu/RePEc/bocode/e/EXAMPLE_TRADE_FTA_DATA" , clear egen imp = group(isoimp) egen exp = group(isoexp) preserve keep if category == "MANUF" ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp) estimates save model1, replace restore preserve keep if category == "NONMANUF" ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp) estimates save model2, replace restore preserve keep if category == "TOTAL" ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp) estimates save model3, replace restore estimates use model1.ster estimates store model1 estimates use model2.ster estimates store model2 estimates use model3.ster estimates store model3 coefplot (model1, aseq("Sector 1")) (model2, aseq("Sector 2")) /// (model3, aseq("Sector 3") ciopts(color(red) recast(rcap)) mcolor(red) ), /// keep(fta) /// xline(0) /// ciopts(recast(rcap) color(blue)) /// msymbol(O) mcolor(blue) /// ytitle("Coefficient of lndistw") /// xtitle("") /// xlabel( , angle(0) labsize(medium)) /// vertical aseq swapnames nokey /// xlabel(1 "11", add custom labcolor(black) labsize(*0.64)) /// xlabel(2 "22", add custom labcolor(orange) labsize(*0.64)) /// xlabel(3 "23" , add custom labcolor(black) labsize(*0.64))
use "http://fmwww.bc.edu/RePEc/bocode/e/EXAMPLE_TRADE_FTA_DATA" , clear
egen imp = group(isoimp)
egen exp = group(isoexp)
preserve
keep if category == "MANUF"
ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp)
estimates save model1, replace
restore
preserve
keep if category == "NONMANUF"
ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp)
estimates save model2, replace
restore
preserve
keep if category == "TOTAL"
ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp)
estimates save model3, replace
restore
estimates use model1.ster
estimates store model1
estimates use model2.ster
estimates store model2
estimates use model3.ster
estimates store model3
coefplot (model1, aseq("Sector 1")) (model2, aseq("Sector 2")) ///
(model3, aseq("Sector 3") ciopts(color(red) recast(rcap)) mcolor(red) ), ///
keep(fta) ///
xline(0) ///
ciopts(recast(rcap) color(blue)) ///
msymbol(O) mcolor(blue) ///
ytitle("Coefficient of lndistw") ///
xtitle("") ///
xlabel(, labcolor(none) angle(0) labsize(medium)) ///
vertical aseq swapnames nokey ///
xlabel(1 "11", add custom labcolor(black) labsize(*0.64)) ///
xlabel(2 "22", add custom labcolor(orange) labsize(*0.64)) ///
xlabel(3 "23" , add custom labcolor(black) labsize(*0.64))
Comment