Dear Stata Listers,
I hope you are doing well.
I have a district-year (bench is district and yeardecision is year) panel data set and I want to construct a bar chart with average before and after a reform in 2010.
My plan is to construct mean and standard error and then use the following code to construct the bar graph with standard errors:
My original data set looks like this:
I run the following code, where I first make the average of pre and post reform State Wins (my variable of interest) but I am having problem constructing standard errors. The code up till this point works:
However, when I try to construct the standard errors using following code, I get all missing values for my PreRefStateWinsSE and PostPostRefStateWinsSE variables :
How may I proceed to get a bar chart with standard errors of pre and post reform years with my dataset? Any help in this regard will be really appreciated. Thanks.
Cheers,
Roger
I hope you are doing well.
I have a district-year (bench is district and yeardecision is year) panel data set and I want to construct a bar chart with average before and after a reform in 2010.
My plan is to construct mean and standard error and then use the following code to construct the bar graph with standard errors:
Code:
graph twoway (bar PreRefStateWinsMean PostRefStateWinsMean ) (rcap SEPreRefStateWinsMean SEPostRefStateWinsMean)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str5 bench int yeardecision float(StateWins caselag) byte Reform_Exposure float public_services "phc" 2009 .5714286 .5625 0 . "quehc" 2009 .52 2.7142856 0 .071428575 "rwphc" 2009 .5 2 0 . "sukhc" 2009 .6875 .5032258 0 . "" 2010 . 1 . . "abohc" 2010 .6666667 .3333333 0 . "banhc" 2010 .4 2 0 . end
I run the following code, where I first make the average of pre and post reform State Wins (my variable of interest) but I am having problem constructing standard errors. The code up till this point works:
Code:
***Creating Variables to Construct Bar Chart generate sdStateWins = . replace sdStateWins = StateWins collapse (mean) StateWins (sd) sdStateWins (mean) caselag (mean) public_services (mean) public_official (mean) provincial_govt (mean) dist_govt (mean) fed_govt (mean) govresp (mean) firmvsstate , by(bench yeardecision) summarize StateWins if yeardecision < 2010 generate PreRefStateWinsMean = r(mean) summarize StateWins if yeardecision >= 2010 generate PostRefStateWinsMean = r(mean) set more off list PreRefStateWinsMean PostRefStateWinsMean //works till here graph bar PreRefStateWinsMean PostRefStateWinsMean
Code:
generate PreRefStateWinsSE = PreRefStateWinsMean + invttail(92,0.025)*(sdStateWins / sqrt(93)) //92 are df generate PostRefStateWinsSE = PostRefStateWinsMean + invttail(100,0.025)*(sdStateWins / sqrt(101)) //100 are df
Cheers,
Roger
Comment