Dear community,


I created this plot for the sector-level coefficients of a gravity model (see attached). As I want to compare these coefficients with an aggregate estimate, I would like to add a grey band, for the confidence interval of this aggregate estimate. For now, I have only defined the two limits of the confidence interval (ll and ul), but I don't manage to create a band out of them inside coefplot (I tried with the addplot(rarea ll ul range, color()) line, but it doesn't produce anything. Any hint is highly appreciated!
This is my code (I have stored the estimation results of the sector-level regressions as separate .ster files (e.g. sector22.ster)):
gen ll=0.158
gen ul=2.67
gen range = cond(_n==1, _n-.5, _n+.5)
coefplot (sector1, aseq("Sector 1")) (sector2, aseq("Sector 2")) (sector3, aseq("Sector 3")) (sector4, aseq("Sector 4")) ///
(sector5, aseq("Sector 5")) (sector6, aseq("Sector 6")) (sector7, aseq("Sector 7")) (sector8, aseq("Sector 8")) ///
(sector9, aseq("Sector 9") ciopts(color(green) recast(rcap)) mcolor(green)) ///
(sector10, aseq("Sector 10")) (sector11, aseq("Sector 11")) (sector12, aseq("Sector 12")) (sector13, aseq("Sector 13")) ///
(sector14, aseq("Sector 14")) (sector15, aseq("Sector 15")) ///
(sector16, aseq("Sector 16") ciopts(color(orange) recast(rcap)) mcolor(orange)) ///
(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")) , ///
keep(lngdp_o) ///
ciopts(recast(rcap) color(blue)) ///
msymbol(O) mcolor(blue) ///
ytitle("Coefficient of source GDP (log)") ///
xtitle(" ") ///
yline (1.417, lcolor(red)) ///
yline (0, lcolor(black)) ///
xlabel( , labcolor(none) angle(0) labsize(medium)) ///
vertical aseq swapnames nokey ///
level(90) ///
xtitle("Sector") ///
addplot(rarea ll ul range, color(gs8%40)) ///
xlabel(1 "11" 2 "21" 3 "22" 4 "23" 5 "31" 6 "32" 7 "33" 8 "42", add custom labcolor(black) labsize(*0.64)) ///
xlabel(9 "44", add custom labcolor(green) labsize(*0.64)) ///
xlabel(10 "45" 11 "48" 12 "49" 13 "51" 14 "52" 15 "53", add custom labcolor(black) labsize(*0.64)) ///
xlabel(16 "54", add custom labcolor(orange) labsize(*0.64)) ///
xlabel(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" 23 "81", add custom labcolor(black) labsize(*0.64))
drop ll ul range
Best Noemi
I created this plot for the sector-level coefficients of a gravity model (see attached). As I want to compare these coefficients with an aggregate estimate, I would like to add a grey band, for the confidence interval of this aggregate estimate. For now, I have only defined the two limits of the confidence interval (ll and ul), but I don't manage to create a band out of them inside coefplot (I tried with the addplot(rarea ll ul range, color()) line, but it doesn't produce anything. Any hint is highly appreciated!
This is my code (I have stored the estimation results of the sector-level regressions as separate .ster files (e.g. sector22.ster)):
gen ll=0.158
gen ul=2.67
gen range = cond(_n==1, _n-.5, _n+.5)
coefplot (sector1, aseq("Sector 1")) (sector2, aseq("Sector 2")) (sector3, aseq("Sector 3")) (sector4, aseq("Sector 4")) ///
(sector5, aseq("Sector 5")) (sector6, aseq("Sector 6")) (sector7, aseq("Sector 7")) (sector8, aseq("Sector 8")) ///
(sector9, aseq("Sector 9") ciopts(color(green) recast(rcap)) mcolor(green)) ///
(sector10, aseq("Sector 10")) (sector11, aseq("Sector 11")) (sector12, aseq("Sector 12")) (sector13, aseq("Sector 13")) ///
(sector14, aseq("Sector 14")) (sector15, aseq("Sector 15")) ///
(sector16, aseq("Sector 16") ciopts(color(orange) recast(rcap)) mcolor(orange)) ///
(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")) , ///
keep(lngdp_o) ///
ciopts(recast(rcap) color(blue)) ///
msymbol(O) mcolor(blue) ///
ytitle("Coefficient of source GDP (log)") ///
xtitle(" ") ///
yline (1.417, lcolor(red)) ///
yline (0, lcolor(black)) ///
xlabel( , labcolor(none) angle(0) labsize(medium)) ///
vertical aseq swapnames nokey ///
level(90) ///
xtitle("Sector") ///
addplot(rarea ll ul range, color(gs8%40)) ///
xlabel(1 "11" 2 "21" 3 "22" 4 "23" 5 "31" 6 "32" 7 "33" 8 "42", add custom labcolor(black) labsize(*0.64)) ///
xlabel(9 "44", add custom labcolor(green) labsize(*0.64)) ///
xlabel(10 "45" 11 "48" 12 "49" 13 "51" 14 "52" 15 "53", add custom labcolor(black) labsize(*0.64)) ///
xlabel(16 "54", add custom labcolor(orange) labsize(*0.64)) ///
xlabel(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" 23 "81", add custom labcolor(black) labsize(*0.64))
drop ll ul range
Best Noemi

Comment