Hi all,
I need to add standard error bars to the bar chart below.
My question is whether there is a way to add SE bars when plotting more than one variable?
My survey data contains a categorical variable determing which treatment the subject was allocated to (Treatment group).
Within each treatment subjects had to answer two questions "Too_Cheap" and "Cheap".
This is the code I used to plot the graph below

When I try use the rcast command as follows I get the message "rcap requires 3 variables: hiToo_Cheap loToo_Cheap hiCheap loCheap Treatment_Group"
Here is also some data
Would be super grateful for any help,
I need to add standard error bars to the bar chart below.
My question is whether there is a way to add SE bars when plotting more than one variable?
My survey data contains a categorical variable determing which treatment the subject was allocated to (Treatment group).
Within each treatment subjects had to answer two questions "Too_Cheap" and "Cheap".
This is the code I used to plot the graph below
Code:
collapse (mean) meanToo_Cheap = Too_Cheap meanCheap = Cheap (sd) sdToo_Cheap = Too_Cheap sdCheap = Cheap (count) nToo_Cheap= Too_Cheap nCheap= Cheap, by(Treatment_Group) generate hiToo_Cheap = meanToo_Cheap + invttail(nToo_Cheap-1,0.025)*(sdToo_Cheap / sqrt(nToo_Cheap)) generate loToo_Cheap = meanToo_Cheap - invttail(nToo_Cheap-1,0.025)*(sdToo_Cheap / sqrt(nToo_Cheap)) generate hiCheap = meanCheap + invttail(nCheap-1,0.025)*(sdCheap / sqrt(nCheap)) generate loCheap = meanCheap - invttail(nCheap-1,0.025)*(sdCheap / sqrt(nCheap)) graph bar meanToo_Cheap meanCheap, over(Treatment_Group) graph twoway (bar meanToo_Cheap meanCheap Treatment_Group) (rcap hiToo_Cheap loToo_Cheap hiCheap loCheap Treatment_Group)
When I try use the rcast command as follows I get the message "rcap requires 3 variables: hiToo_Cheap loToo_Cheap hiCheap loCheap Treatment_Group"
Here is also some data
Would be super grateful for any help,
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte Treatment_Group int Cheap double Too_Cheap 2 1 0 1 8 5 2 12 5 3 12 11 2 17 15 3 16 13 3 10 5 3 5 1 2 20 10 2 10 3 3 30 20 1 10 5 3 20 5 2 20 10 3 15 10 2 16 10 3 17 12 1 12 5 2 25 5 3 20 25 1 20 15 1 25 35 3 20 15 1 9 19 1 29 20 1 20 10 1 30 20 4 10 9 3 30 10 2 20 15 3 10 5 1 18 10 1 25 20 2 25 10 3 15 5 3 25 15 4 15 1 2 10 1 1 20 10 2 30 10 3 20 15 4 20 10 2 25 20 1 25 12 2 30 25 1 25 20 2 30 20 4 10 5 3 19 29 2 45 15 3 35 20 2 20 9 4 30 20 1 30 15 1 20 5 3 30 25 2 25 15 1 20 10 3 30 20 4 25 10 4 20 10 1 25 9.99 3 30 10 1 20 3 3 40 40 1 20 15 3 25 10 4 30 20 3 25 15 3 20 10 3 18 10 4 20 10 1 30 10 4 30 20 4 30 20 3 10 10 4 12 5 1 15 5 4 40 25 4 60 20 2 25 15 3 15 0 2 39 30 1 40 35 1 22 15 1 25 15 3 25 25 3 25 18 1 20 10 2 29 15 1 20 10 2 35 20 2 15 5 3 45 20 1 40 18 3 40 30 3 35 20 1 40 10 3 30 25 1 30 20 end label values Treatment_Group Treatment_labels label def Treatment_labels 1 "1. Control", modify label def Treatment_labels 2 "2. SOC", modify label def Treatment_labels 3 "3. ENV", modify label def Treatment_labels 4 "4. SOC*ENV", modify
Comment