/* ms2_fig1.do do-file to generate figure 1 for SJ manuscript: "Accomodating covariates in ROC analysis". Janes H, Longton G, and Pepe M coordinates for density curves in panel (1) were generated elsewhere and are imported from data files: Figure1a_Z0.dat Figure1a_Z1.dat Figure1a_PooledScen1.dat Figure1a_PooledScen2.dat coordinates for ROC curves were generated elsewhere and imported from data file: Figure1b.dat last update: 4/22/2008 */ version 10.0 set scheme sj local f1 "Figure1a_Z0" local f2 "Figure1a_Z1" local f3 "Figure1a_PooledScen1" local f4 "Figure1a_PooledScen2" local subt1 "Z = 0" local subt2 "Z = 1" local subt3 "pooled data scenario 1" local subt4 "pooled data scenario 2" local rho3 ".50" local rho4 ".50" local xax xscale(r(-5.5,10)) xlab(-5(5)10) #delimit ; local legend1 `" legend(order( 1 2 ) ring(0) pos(2) cols(1) size(3.3) label(1 "controls") label(2 "cases") keygap(2) rowgap(.6) symx(8) bmargin(t=2 r=0) region(style(none)) ) "' ; #delimit cr forvalues i = 2/4 { local legend`i' "legend(off)" } local txt1 "" local txt2 "" forvalues i = 3/4 { local txt`i' `"text(.17 -2.3 "P(D=1) = `rho`i''", placement(left) size(2.6))"' } // density plots for panel (a): forvalues i = 1/4 { tempname g`i' insheet using `f`i''.dat, comma clear #delimit ; scatter ydot xdot, connect(l) m(none) lwidth(*1.5) lp(shortdash) lc(gs0) || scatter ysolid xsolid, connect(l) m(none) lwidth(*1.5) lp(solid) lc(gs0) `xax' xline(2.5, lw(*1) lc(gs9) ) plotregion(style(none)) yscale(noline r(0,0.3)) ylab(none) subtitle("`subt`i''",ring(0) pos(10) margin(l=0 t=1) justification(left) size(3.5)) `txt`i'' `legend`i'' scheme(s1mono) name(`g`i'') ; } ; graph combine `g1' `g2' `g3' `g4', cols(1) xcommon nocopies iscale(*1.2) imargin(t=2 b=1) l1("density", size(5) margin(b=8 r=3)) title("(a)", margin(t=0 b=3) size(4.7) justification(center) width(35)) graphregion(margin(r=5)) name(ga, replace) ; #delimit cr insheet using Figure1b.dat, comma clear compress gen xpt = . gen ypt = . forvalues i = 1/4 { replace xpt = xdot`i' if _n == `i' replace ypt = ydot`i' if _n == `i' } sort x gen forty5 = x if _n==1 | _n==_N // panel (b): #delimit ; twoway (line ysolid x, clw(*1.5) clp(solid) lc(gs0) sort(x)) (line ydash x, clw(*1.5) clp(dash) lc(gs0) sort(x)) (line ydot x, clw(*1.5) clp(shortdash_dot) lc(gs0) sort(x)) (line forty5 x, clcolor(gs13) clw(thin) clp(solid)) (scatter ypt xpt, sort(xpt) m(o) mc(gs0) msize(2)), xlab(0 1) ylab(0 1, angle(horizontal)) xline(0(.2)1,lstyle(grid) lcolor(gs13) lw(thin)) yline(0(.2)1,lstyle(grid) lcolor(gs13) lw(thin)) ytitle(TPR, size(4) justification(center) orientation(horizontal)) yscale(titlegap(2)) xtitle(FPR, size(4) justification(center) margin(b=0)) xscale(r(0 1) titlegap(1.5)) legend(order( 1 2 3 ) ring(0) pos(5) cols(1) size(3.0) title("ROC curves", size(3.2) margin(b=2)) label(1 "covariate specific") label(2 "pooled, scenario 1") label(3 "pooled, scenario 2") keygap(2) rowgap(1.0) symx(8) region(fcolor(white) lcolor(white) margin(r=1 l=1 t=1 b=1)) bmargin(r=1 b=3) ) title("(b)", margin(t=2 b=5) size(4.7) justification(center) width(35)) aspectratio(1) plotregion(margin(l=2 r=2 t=2 b=2) ) graphregion(margin(l=5)) name(gb, replace) ; graph combine ga gb, rows(1) nocopies name(fg1, replace) ;