I'm making the following graph, but want to remove the lines between the marker at "4+" and the marker at "+1". I want to keep the lines between all the other markers. I've managed to do this in a graph with only one line by drawing two separate lines, one starting at "-6" ending at "4+" and then a new line from "+1" to "+6", but I can't make it work when I have several strata.
*Age-stratified
clear
input strata time OR lower upper
0 1 1.24 0.98 1.55
0 2 1.22 0.98 1.52
0 3 1.26 1.02 1.57
0 4 1.39 1.13 1.70
0 5 1.63 1.34 1.98
0 6 2.66 2.24 3.17
0 7 2.33 1.96 2.78
0 8 1.48 1.22 1.78
0 9 1.48 1.23 1.78
0 10 1.58 1.46 1.72
0 11 0.93 0.73 1.20
0 12 1.01 0.79 1.30
0 13 1.32 1.04 1.68
0 14 1.14 0.90 1.45
0 15 1.20 0.94 1.53
0 16 1.13 0.87 1.46
1 1 1.12 0.90 1.38
1 2 1.34 1.09 1.65
1 3 1.29 1.06 1.58
1 4 1.08 0.89 1.32
1 5 1.84 1.51 2.24
1 6 2.78 2.35 3.29
1 7 2.15 1.83 2.54
1 8 2.00 1.70 2.35
1 9 1.61 1.36 1.92
1 10 1.60 1.49 1.72
1 11 1.03 0.82 1.30
1 12 1.21 0.96 1.52
1 13 1.28 1.00 1.64
1 14 1.02 0.80 1.29
1 15 1.02 0.81 1.30
1 16 1.51 1.20 1.89
2 1 0.75 0.44 1.28
2 2 0.78 0.47 1.28
2 3 1.51 0.99 2.29
2 4 1.46 0.90 2.34
2 5 1.47 0.93 2.34
2 6 2.33 1.60 3.40
2 7 1.76 1.19 2.60
2 8 2.20 1.56 3.11
2 9 1.58 1.08 2.30
2 10 1.81 1.54 2.12
2 11 1.85 1.18 2.89
2 12 2.29 1.40 3.77
2 13 2.32 1.33 4.03
2 14 1.79 1.09 2.95
2 15 1.41 0.81 2.47
2 16 2.38 1.45 3.91
end
gen ny_time = time
gen ny_time1 = ny_time-0.1
gen ny_time2 = ny_time+0.1
twoway ///
(scatter OR time if strata==0 , c(l) mcolor(edkblue) lcolor(edkblue) ) ///
(rcap upper lower time if strata==0 , lcolor(edkblue) ) ///
(scatter OR ny_time1 if strata==1 , c(l)mcolor(lavender) lcolor(lavender)lp(dash_dot) ) ///
(rcap upper lower ny_time1 if strata==1 , lcolor(lavender)) ///
(scatter OR ny_time2 if strata==2 , c(l)mcolor(forest_green) lcolor(forest_green)lp(shortdash) ) ///
(rcap upper lower ny_time2 if strata==2 , lcolor(forest_green)) ///
, scheme(s1color) ///
legend(label(1 "Age <30") label(3 "Age 30-49") label(5 "Age 50-67") ///
order(5 3 1 ) ///
ring(0) pos(11) col(1) ) ///
ylabel(1(1)5, angle(horiz) format(%2.0f) ) ///
ytitle("OR") ///
xlabel(1 "-6" 2 "-5" 3 "-4" 4 "-3" 5 "-2" 6 "-1" 7 "1" 8 "2" 9 "3" 10 "4+" 11 "+1" 12 "+2" 13 "+3" 14 "+4" 15 "+5" 16 "+6", labsize(small) angle(horiz) ) ///
xtitle("Years before, during (between red lines) and after", size(medsmall))title("Stata example") ///
xline (7 10)
Silje
*Age-stratified
clear
input strata time OR lower upper
0 1 1.24 0.98 1.55
0 2 1.22 0.98 1.52
0 3 1.26 1.02 1.57
0 4 1.39 1.13 1.70
0 5 1.63 1.34 1.98
0 6 2.66 2.24 3.17
0 7 2.33 1.96 2.78
0 8 1.48 1.22 1.78
0 9 1.48 1.23 1.78
0 10 1.58 1.46 1.72
0 11 0.93 0.73 1.20
0 12 1.01 0.79 1.30
0 13 1.32 1.04 1.68
0 14 1.14 0.90 1.45
0 15 1.20 0.94 1.53
0 16 1.13 0.87 1.46
1 1 1.12 0.90 1.38
1 2 1.34 1.09 1.65
1 3 1.29 1.06 1.58
1 4 1.08 0.89 1.32
1 5 1.84 1.51 2.24
1 6 2.78 2.35 3.29
1 7 2.15 1.83 2.54
1 8 2.00 1.70 2.35
1 9 1.61 1.36 1.92
1 10 1.60 1.49 1.72
1 11 1.03 0.82 1.30
1 12 1.21 0.96 1.52
1 13 1.28 1.00 1.64
1 14 1.02 0.80 1.29
1 15 1.02 0.81 1.30
1 16 1.51 1.20 1.89
2 1 0.75 0.44 1.28
2 2 0.78 0.47 1.28
2 3 1.51 0.99 2.29
2 4 1.46 0.90 2.34
2 5 1.47 0.93 2.34
2 6 2.33 1.60 3.40
2 7 1.76 1.19 2.60
2 8 2.20 1.56 3.11
2 9 1.58 1.08 2.30
2 10 1.81 1.54 2.12
2 11 1.85 1.18 2.89
2 12 2.29 1.40 3.77
2 13 2.32 1.33 4.03
2 14 1.79 1.09 2.95
2 15 1.41 0.81 2.47
2 16 2.38 1.45 3.91
end
gen ny_time = time
gen ny_time1 = ny_time-0.1
gen ny_time2 = ny_time+0.1
twoway ///
(scatter OR time if strata==0 , c(l) mcolor(edkblue) lcolor(edkblue) ) ///
(rcap upper lower time if strata==0 , lcolor(edkblue) ) ///
(scatter OR ny_time1 if strata==1 , c(l)mcolor(lavender) lcolor(lavender)lp(dash_dot) ) ///
(rcap upper lower ny_time1 if strata==1 , lcolor(lavender)) ///
(scatter OR ny_time2 if strata==2 , c(l)mcolor(forest_green) lcolor(forest_green)lp(shortdash) ) ///
(rcap upper lower ny_time2 if strata==2 , lcolor(forest_green)) ///
, scheme(s1color) ///
legend(label(1 "Age <30") label(3 "Age 30-49") label(5 "Age 50-67") ///
order(5 3 1 ) ///
ring(0) pos(11) col(1) ) ///
ylabel(1(1)5, angle(horiz) format(%2.0f) ) ///
ytitle("OR") ///
xlabel(1 "-6" 2 "-5" 3 "-4" 4 "-3" 5 "-2" 6 "-1" 7 "1" 8 "2" 9 "3" 10 "4+" 11 "+1" 12 "+2" 13 "+3" 14 "+4" 15 "+5" 16 "+6", labsize(small) angle(horiz) ) ///
xtitle("Years before, during (between red lines) and after", size(medsmall))title("Stata example") ///
xline (7 10)
Silje
Comment