/******************************************************************************* *Title: Figures for Wagner et al. 2018 "The role of price and convenience in use of oral rehydration salts to treat child diarrhea" *Created by: Zachary Wagner *Created on: 8-1-2018 *Last modified on: 12-06-2018 *Last modified by: Zachary Wagner *Purpose: This file creates figures presented in the PLOS Medicine paper *******************************************************************************/ clear all set more off *Set Central Directory cd "~/Dropbox/Uganda ORS/VHT study" *Setting data is location global data “S1_data” *setting folder to store figures global figures "figures" *The Following Files Have Been Run: * "Baseline_Clean.do" * "Baseline_ChildLevel" * "Endline_Clean.do" * "Endline_ChildLevel" * "Variables.do" insheet using "$data", clear names *1. creating variables to store parameters to graph gen axis=1 if _n==1 replace axis=3 if _n==2 replace axis=5 if _n==3 replace axis=7 if _n==4 gen axis2=1 if _n==1 replace axis2=3 if _n==2 replace axis2=5 if _n==3 replace axis2=7 if _n==4 gen axis3=1 if _n==1 replace axis3=3 if _n==2 replace axis3=5 if _n==3 replace axis3=7 if _n==4 gen series1=. gen lower1=. gen upper1=. gen series2=. gen lower2=. gen upper2=. gen series3=. gen lower3=. gen upper3=. gen series4=. gen lower4=. gen upper4=. reg ors I.treat, cluster(village) local se_ors1=_se[1.treat] local se_ors2=_se[2.treat] local se_ors3=_se[3.treat] reg ors_zinc I.treat, cluster(village) local se_ors_zinc1=_se[1.treat] local se_ors_zinc2=_se[2.treat] local se_ors_zinc3=_se[3.treat] reg ors_sameday I.treat, cluster(village) local se_ors_same1=_se[1.treat] local se_ors_same2=_se[2.treat] local se_ors_same3=_se[3.treat] reg anti I.treat, cluster(village) local se_anti1=_se[1.treat] local se_anti2=_se[2.treat] local se_anti3=_se[3.treat] ci proportions ors if treat==0 replace series1=r(mean) if _n==1 ci proportions ors if treat==1 replace series1=r(mean) if _n==2 replace upper1=r(mean)+(1.96*`se_ors1') if _n==2 replace lower1=r(mean)-(1.96*`se_ors1') if _n==2 ci proportions ors if treat==2 replace series1=r(mean) if _n==3 replace upper1=r(mean)+(1.96*`se_ors2') if _n==3 replace lower1=r(mean)-(1.96*`se_ors2') if _n==3 ci proportions ors if treat==3 replace series1=r(mean) if _n==4 replace upper1=r(mean)+(1.96*`se_ors3') if _n==4 replace lower1=r(mean)-(1.96*`se_ors3') if _n==4 ci proportions ors_zinc if treat==0 replace series2=r(mean) if _n==1 ci proportions ors_zinc if treat==1 replace series2=r(mean) if _n==2 replace upper2=r(mean)+(1.96*`se_ors_zinc1') if _n==2 replace lower2=r(mean)-(1.96*`se_ors_zinc1') if _n==2 ci proportions ors_zinc if treat==2 replace series2=r(mean) if _n==3 replace upper2=r(mean)+(1.96*`se_ors_zinc2') if _n==3 replace lower2=r(mean)-(1.96*`se_ors_zinc2') if _n==3 ci proportions ors_zinc if treat==3 replace series2=r(mean) if _n==4 replace upper2=r(mean)+(1.96*`se_ors_zinc3') if _n==4 replace lower2=r(mean)-(1.96*`se_ors_zinc3') if _n==4 ci proportions ors_sameday if treat==0 replace series3=r(mean) if _n==1 ci proportions ors_sameday if treat==1 replace series3=r(mean) if _n==2 replace upper3=r(mean)+(1.96*`se_ors_same1') if _n==2 replace lower3=r(mean)-(1.96*`se_ors_same1') if _n==2 ci proportions ors_sameday if treat==2 replace series3=r(mean) if _n==3 replace upper3=r(mean)+(1.96*`se_ors_same2') if _n==3 replace lower3=r(mean)-(1.96*`se_ors_same2') if _n==3 ci proportions ors_sameday if treat==3 replace series3=r(mean) if _n==4 replace upper3=r(mean)+(1.96*`se_ors_same3') if _n==4 replace lower3=r(mean)-(1.96*`se_ors_same3') if _n==4 ci proportions anti if treat==0 replace series4=r(mean) if _n==1 ci proportions anti if treat==1 replace series4=r(mean) if _n==2 replace upper4=r(mean)+(1.96*`se_anti1') if _n==2 replace lower4=r(mean)-(1.96*`se_anti1') if _n==2 ci proportions anti if treat==2 replace series4=r(mean) if _n==3 replace upper4=r(mean)+(1.96*`se_anti2') if _n==3 replace lower4=r(mean)-(1.96*`se_anti2') if _n==3 ci proportions anti if treat==3 replace series4=r(mean) if _n==4 replace upper4=r(mean)+(1.96*`se_anti3') if _n==4 replace lower4=r(mean)-(1.96*`se_anti3') if _n==4 forvalues i=1/4{ replace series`i'=series`i'*100 replace upper`i'=upper`i'*100 replace lower`i'=lower`i'*100 } *2. Plotting parameters for different outcomes (Figure 2) *****ORS twoway (bar series1 axis, color(ebblue) ) /// (rcap upper1 lower1 axis), /// xlabel( 1 "Control" 3 "Free+Convenient" 5 "Convenient Only" 7 "Free Only" ) /// ylabel(0(10)100) /// legend(off) /// xtitle("") /// ytitle("% of Cases") /// scheme(s1color) /// title("A. Treated with ORS") /// saving(fig2a, replace) graph export "$figures/figure2a.tif", replace *****ORS + Zinc twoway (bar series2 axis2, color(ebblue) ) /// (rcap upper2 lower2 axis2), /// xlabel( 1 "Control" 3 "Free+Convenient" 5 "Convenient Only" 7 "Free Only" ) /// ylabel(0(10)100) /// xtitle("") /// ytitle("% of Cases") /// legend(order( 2 "95% CI relative to control")) /// scheme(s1color) /// legend(off) /// title("B. Treated with ORS+Zinc") /// saving(fig2b, replace) graph export "$figures/figure2b.tif", replace *****Time twoway (bar series3 axis3, color(ebblue) ) /// (rcap upper3 lower3 axis3), /// xlabel( 1 "Contrl" 3 "Free+Convenient" 5 "Convenient Only" 7 "Free Only" ) /// ylabel(0(10)100) /// xtitle("") /// ytitle("% of Cases") /// legend(order( 2 "95% CI relative to control")) /// scheme(s1color) /// legend(off) /// title("C. ORS on same day as diarrhea onset") /// saving(fig2c, replace) graph export "$figures/figure2c.tif", replace *****Antibiotics twoway (bar series4 axis, color(ebblue) ) /// (rcap upper4 lower4 axis), /// xlabel( 1 "Control" 3 "Free+Convenient" 5 "Convenient Only" 7 "Free Only" ) /// ylabel(0(10)100) /// xtitle("") /// ytitle("% of Cases") /// legend(order( 2 "95% CI relative to control")) /// scheme(s1color) /// legend(off) /// title("D. Treated with Antibiotics") /// saving(fig2d, replace) graph export "$figures/figure2d.tif", replace graph combine fig2a.gph fig2b.gph fig2c.gph fig2d.gph, iscale(.5) scheme(s1color) graph export "$figures/figure2.pdf", replace graph export "$figures/figure2.tif", replace *3. Doing same procedure for Figure 3 use "$data", clear *creating categories for the points that create quartiles gen ors_vil_cat=1 if ors_vil<=.44 replace ors_vil_cat=2 if ors_vil>.44 & ors_vil<=.58 replace ors_vil_cat=3 if ors_vil>.58 & ors_vil<=.78 replace ors_vil_cat=4 if ors_vil>.78 gen est=. gen lb=. gen ub=. forvalues i=1/4{ quietly logit ors I.treat if ors_vil_cat==`i', cluster(village) quietly margins, dydx(1.treat) replace est=round(el(r(table), 1, 2), .001) if _n==`i' replace lb=round(el(r(table), 5, 2), .001) if _n==`i' replace ub=round(el(r(table), 6, 2), .001) if _n==`i' } gen axis=1 if _n==1 replace axis=3 if _n==2 replace axis=5 if _n==3 replace axis=7 if _n==4 twoway(scatter est axis, color(black))(rcap ub lb axis, lcolor(black)), /// xlabel(1 "<25% " 3 "25-58%" 5 "59-78%" 7 ">78%") /// legend(order(1 "Estimate" 2 "95% CI")) /// xtitle("Baseline ORS Coverage (Village Level)") /// ytitle("Effec Size") /// scheme(s2mono) /// yline(0, lpattern(dash) lcolor(black)) graph export "$figures/figure3.tif", replace