log using FramSBPbmiSex.log, replace * FramSBPbmiSex.log * * Regression of systolic blood pressure against body mass * index at baseline in men and women from the Framingham Heart Study. * set more on use "2.20.Framingham.dta", clear codebook sex regress sbp bmi if sex == 1 predict yhatmen, xb regress sbp bmi if sex == 2 predict yhatwom, xb sort bmi * * Scatter plot with expected sbp for women * scatter sbp bmi if sex==2 , msymbol(Oh) /// || lfit sbp bmi if sex==2 /// , lpattern(dash) xlabel(15 (15) 60) /// ylabel( 100 (50) 250 ) ytitle(Systolic Blood Pressure) more * * Scatter plot with expected sbp for men * scatter sbp bmi if sex==1 , msymbol(Oh) /// || lfit sbp bmi if sex==1 /// , xlabel(15 (15) 60) /// ylabel( 100 (50) 250 ) ytitle(Systolic Blood Pressure) more * * Combining the previous two graphs with a by(sex) option and adding * some formatting gives gives the following figure * scatter sbp bmi , msymbol(Oh) mcolor(gs10) /// || line yhatmen bmi if sex == 1, lwidth(medthick) /// || line yhatwom bmi, lwidth(medthick) lpattern(dash) /// ||, by(sex) ytitle(Systolic Blood Pressure) xsize(8) /// ylabel( 100 (50) 250) ymtick(75 (25) 225) /// xtitle(Body Mass Index) xlabel( 15 (15) 60) xmtick(20 (5) 55) /// legend(order(1 "Observed" 2 "Expected, Men" 3 /// "Expected, Women") rows(1)) log close