I use the data below to plot estimates with confidence limits:
clear
input year beta ci5 ci95 pvalue
1999 0.390337619 -0.876345001 1.657020238 0.527644768
2001 -0.281463106 -1.14277483 0.579848618 0.503264501
2003 -0.753077604 -1.49646223 -0.009692978 0.047349224
2005 -0.295911126 -0.735095768 0.143273516 0.175219436
2007 0.976340177 0.206120956 1.746559398 0.015560029
2010 0.080218534 -0.428463191 0.588900259 0.745605829
2012 0.021721372 -0.61379414 0.657236884 0.943868989
2014 -0.05203667 -0.658245394 0.554172054 0.859691155
end
I do so using the community-contributed command eclplot
and the code that I run is the following:
eclplot beta ci5 ci95 year, eplot(bar) estopts(barwidth(0.25)) title("Portfolio") ///
rplottype( rspike) estopts2(bcolor(black)) ytitle("alpha (b.p.)") xtitle(" years") ///
yline(0,lstyle(foreground)) xline(2007, lcolor(blue))
How can I add the p-value above the corresponding bar?
I would also like to draw a thick reference line (light gray) for year 2007
.
The following works for me:
generate a = 2
generate b = round(pvalue, .001)
levelsof year, local(allyears) clean
eclplot beta ci5 ci95 year, eplot(bar) estopts(barwidth(0.25)) ///
title("Portfolio") rplottype( rspike) estopts2(bcolor(black)) ///
ytitle("alpha (b.p.)") xtitle("years") yline(0,lstyle(foreground)) ///
xline(2007, lcolor(gs9) lwidth(thick)) addplot(scatter a year, mlabel(b) ///
msymbol(i) mlabposition(6)) xlabel(`allyears')