-------------------------------------------------------------------------------------------------------- name: log: C:\MyDocs\MPH\LectureNotes\ClassDoLogData\linearRegression\FramSBPbmiSex.log log type: text opened on: 20 Nov 2009, 16:07:11 . * 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 -------------------------------------------------------------------------------------------------------- sex Sex -------------------------------------------------------------------------------------------------------- type: numeric (float) label: sex range: [1,2] units: 1 unique values: 2 missing .: 0/4699 tabulation: Freq. Numeric Label 2049 1 Men 2650 2 Women . regress sbp bmi if sex == 1 Source | SS df MS Number of obs = 2047 -------------+------------------------------ F( 1, 2045) = 121.09 Model | 44504.0296 1 44504.0296 Prob > F = 0.0000 Residual | 751572.011 2045 367.516876 R-squared = 0.0559 -------------+------------------------------ Adj R-squared = 0.0554 Total | 796076.041 2046 389.088974 Root MSE = 19.171 ------------------------------------------------------------------------------ sbp | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- bmi | 1.375953 .1250382 11.00 0.000 1.130738 1.621168 _cons | 96.43061 3.272571 29.47 0.000 90.01269 102.8485 ------------------------------------------------------------------------------ . predict yhatmen, xb (9 missing values generated) . regress sbp bmi if sex == 2 Source | SS df MS Number of obs = 2643 -------------+------------------------------ F( 1, 2641) = 428.48 Model | 229129.452 1 229129.452 Prob > F = 0.0000 Residual | 1412279.85 2641 534.751932 R-squared = 0.1396 -------------+------------------------------ Adj R-squared = 0.1393 Total | 1641409.31 2642 621.275286 Root MSE = 23.125 ------------------------------------------------------------------------------ sbp | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- bmi | 2.045966 .0988403 20.70 0.000 1.852154 2.239779 _cons | 81.30435 2.548909 31.90 0.000 76.30629 86.30241 ------------------------------------------------------------------------------ . predict yhatwom, xb (9 missing values generated) . 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 name: log: C:\MyDocs\MPH\LectureNotes\ClassDoLogData\linearRegression\FramSBPbmiSex.log log type: text closed on: 20 Nov 2009, 16:08:07 --------------------------------------------------------------------------------------------------------