I hope all is well with you. I wanted to create a bar chart with three bars along with their standard errors. Here is sample of my data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte StateWins int yeardecision str5 bench byte AfterReformJudge 1 2012 "abohc" 0 1 2014 "abohc" 1 0 2013 "abohc" 1 0 2016 "abohc" 1 1 1999 "banhc" 0 1 2013 "banhc" 1 0 2004 "banhc" 0 1 1986 "banhc" 0 1 1990 "banhc" 0 1 2010 "banhc" 0 0 2001 "banhc" 0 end
Previously, when I had a identifier before and after reform, I was able to make two bars by using the following code where former was before reform and latter bar was after the reform:
Code:
preserve collapse (mean) meanStateWins= StateWins (sd) sdStateWins=StateWins (count) n=StateWins, by(AfterReformJudge) generate hiStateWins = meanStateWins + invttail(n-1,0.025)*(sdStateWins / sqrt(n)) generate loStateWins = meanStateWins - invttail(n-1,0.025)*(sdStateWins / sqrt(n)) graph twoway (bar meanStateWins AfterReformJudge) (rcap hiStateWins loStateWins AfterReformJudge) restore
I have tried using if qualifiers to construct yeardecision ranges but I cant seem to make the code work. How can I construct the three bars with their standard errors within these three time ranges?
Any help here will be really appreciated.
Cheers,
Roger
0 Response to Bar Chart with standard errors (move from two to three bars)
Post a Comment