Hello,
Im using the twoway bar command in Stata MP v16.1.
Im trying to create a bar chart comparing rates of hospitalisations for different ethnic groups after adjusting for different variables - so comparing rates by ethnicity in 4 different models, each one controlling for additional characteristics.
The problem is that i want the bars to start at 1 and show the estimated rate above or below 1. The code below gets me bars that start at zero.
Is there a way i can tweak the code below to give me what i need, or do i need to try something else like margins?
I cant post the actual bar chart or data because the data is sensitive - so im hoping the code will give enough information.
My data is long and has 5 variables: ethnicity (9 cats), model (4 cats), irr, lci, uci
There is one additional variable eth_mod which structures the data by model and ethnicity...
[etc - you get the picture re eth_mod so i wont type it all out]
Grateful for any tips.
Many thanks
Im using the twoway bar command in Stata MP v16.1.
Im trying to create a bar chart comparing rates of hospitalisations for different ethnic groups after adjusting for different variables - so comparing rates by ethnicity in 4 different models, each one controlling for additional characteristics.
The problem is that i want the bars to start at 1 and show the estimated rate above or below 1. The code below gets me bars that start at zero.
Is there a way i can tweak the code below to give me what i need, or do i need to try something else like margins?
I cant post the actual bar chart or data because the data is sensitive - so im hoping the code will give enough information.
My data is long and has 5 variables: ethnicity (9 cats), model (4 cats), irr, lci, uci
There is one additional variable eth_mod which structures the data by model and ethnicity...
Code:
gen eth_mod = model if ethnicity==9 replace eth_mod = model+5 if ethnicity==8 replace eth_mod = model+10 if ethnicity==7
Code:
twoway
(bar irr eth_mod if model==1, horizontal) ///
(bar irr eth_mod if model==2, horizontal) ///
(bar irr eth_mod if model==3, horizontal) ///
(bar irr eth_mod if model==4, horizontal) ///
(rcap lci uci eth_mod, horizontal lcolor(black)),
legend(row(1) order(1 "mod1" 2 "mod2" 3 "mod3" 4 "mod4") ///
ylabel(2.5 "eth1) 7.5 "eth2" 12.5 "eth3" 17.5 "eth4" 22.5 "eth5" 27.7 "eth6" 32.5 "eth7" 37.5 "eth8" 42.5 "eth9", noticks angle(horizontal)) ///
ytitle("") xtitle("irr") ///
xline(1, lwidth(thin) lcolor(black) lpattern(solid))
Many thanks

Comment