{smcl} {com}{sf}{ul off}{txt}{.-} name: {res} {txt}log: {res}/Users/steve/Documents/teaching/c2015/biostat208/labs/lab3/lab3.smcl {txt}log type: {res}smcl {txt}opened on: {res}21 Jan 2015, 17:50:43 {txt} {com}. use lab3, clear {txt} {com}. . tab physact, sum(bmi) {txt}comparative {c |} physical {c |} Summary of BMI (kg/m^2) activity {c |} Mean Std. Dev. Freq. {hline 12}{c +}{hline 36} much less {c |} {res} 30.867194 7.0607121 196 {txt}somewhat {c |} {res} 30.343944 6.0039264 502 {txt}about as {c |} {res} 29.031647 5.5072779 917 {txt}somewhat {c |} {res} 27.249821 4.4781094 837 {txt}much more {c |} {res} 26.499412 4.4468966 306 {txt}{hline 12}{c +}{hline 36} Total {c |} {res} 28.579249 5.5177834 2758 {txt} {com}. reg bmi i.physact {txt}Source {c |} SS df MS Number of obs ={res} 2758 {txt}{hline 13}{char +}{hline 30} F( 4, 2753) ={res} 49.01 {txt} Model {char |} {res} 5579.94674 4 1394.98669 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 78359.4937 2753 28.4633105 {txt}R-squared = {res} 0.0665 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.0651 {txt} Total {char |} {res} 83939.4405 2757 30.4459342 {txt}Root MSE = {res} 5.3351 {txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmi{col 23}{c |} Coef.{col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 14}physact {c |} somewhat less active {c |}{col 23}{res}{space 2}-.5232496{col 35}{space 2} .449356{col 46}{space 1} -1.16{col 55}{space 3}0.244{col 63}{space 4}-1.404359{col 76}{space 3} .3578593 {txt}{space 5}about as active {c |}{col 23}{res}{space 2}-1.835547{col 35}{space 2} .419834{col 46}{space 1} -4.37{col 55}{space 3}0.000{col 63}{space 4}-2.658769{col 76}{space 3}-1.012326 {txt}somewhat more active {c |}{col 23}{res}{space 2}-3.617373{col 35}{space 2} .4233525{col 46}{space 1} -8.54{col 55}{space 3}0.000{col 63}{space 4}-4.447494{col 76}{space 3}-2.787253 {txt}{space 4}much more active {c |}{col 23}{res}{space 2}-4.367782{col 35}{space 2} .4880966{col 46}{space 1} -8.95{col 55}{space 3}0.000{col 63}{space 4}-5.324855{col 76}{space 3}-3.410709 {txt}{space 21} {c |} {space 16}_cons {c |}{col 23}{res}{space 2} 30.86719{col 35}{space 2} .3810787{col 46}{space 1} 81.00{col 55}{space 3}0.000{col 63}{space 4} 30.11996{col 76}{space 3} 31.61442 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. * again, showing reference level . reg bmi i.physact, baselevels {txt}Source {c |} SS df MS Number of obs ={res} 2758 {txt}{hline 13}{char +}{hline 30} F( 4, 2753) ={res} 49.01 {txt} Model {char |} {res} 5579.94674 4 1394.98669 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 78359.4937 2753 28.4633105 {txt}R-squared = {res} 0.0665 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.0651 {txt} Total {char |} {res} 83939.4405 2757 30.4459342 {txt}Root MSE = {res} 5.3351 {txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmi{col 23}{c |} Coef.{col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 14}physact {c |} {space 4}much less active {c |}{col 23}{res}{space 2} 0{col 35}{txt} (base) somewhat less active {c |}{col 23}{res}{space 2}-.5232496{col 35}{space 2} .449356{col 46}{space 1} -1.16{col 55}{space 3}0.244{col 63}{space 4}-1.404359{col 76}{space 3} .3578593 {txt}{space 5}about as active {c |}{col 23}{res}{space 2}-1.835547{col 35}{space 2} .419834{col 46}{space 1} -4.37{col 55}{space 3}0.000{col 63}{space 4}-2.658769{col 76}{space 3}-1.012326 {txt}somewhat more active {c |}{col 23}{res}{space 2}-3.617373{col 35}{space 2} .4233525{col 46}{space 1} -8.54{col 55}{space 3}0.000{col 63}{space 4}-4.447494{col 76}{space 3}-2.787253 {txt}{space 4}much more active {c |}{col 23}{res}{space 2}-4.367782{col 35}{space 2} .4880966{col 46}{space 1} -8.95{col 55}{space 3}0.000{col 63}{space 4}-5.324855{col 76}{space 3}-3.410709 {txt}{space 21} {c |} {space 16}_cons {c |}{col 23}{res}{space 2} 30.86719{col 35}{space 2} .3810787{col 46}{space 1} 81.00{col 55}{space 3}0.000{col 63}{space 4} 30.11996{col 76}{space 3} 31.61442 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. * compute mean BMI at each level of physact . forvalues i = 1/5 {c -(} {txt} 2{com}. lincom _cons + `i'.physact {txt} 3{com}. {c )-} {p 0 7}{space 1}{text:( 1)}{space 1} {res}1b.physact + _cons = 0{p_end} {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmi{col 14}{c |} Coef.{col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}(1) {c |}{col 14}{res}{space 2} 30.86719{col 26}{space 2} .3810787{col 37}{space 1} 81.00{col 46}{space 3}0.000{col 54}{space 4} 30.11996{col 67}{space 3} 31.61442 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {p 0 7}{space 1}{text:( 1)}{space 1} {res}2.physact + _cons = 0{p_end} {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmi{col 14}{c |} Coef.{col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}(1) {c |}{col 14}{res}{space 2} 30.34394{col 26}{space 2} .2381172{col 37}{space 1} 127.43{col 46}{space 3}0.000{col 54}{space 4} 29.87704{col 67}{space 3} 30.81085 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {p 0 7}{space 1}{text:( 1)}{space 1} {res}3.physact + _cons = 0{p_end} {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmi{col 14}{c |} Coef.{col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}(1) {c |}{col 14}{res}{space 2} 29.03165{col 26}{space 2} .1761806{col 37}{space 1} 164.78{col 46}{space 3}0.000{col 54}{space 4} 28.68619{col 67}{space 3} 29.37711 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {p 0 7}{space 1}{text:( 1)}{space 1} {res}4.physact + _cons = 0{p_end} {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmi{col 14}{c |} Coef.{col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}(1) {c |}{col 14}{res}{space 2} 27.24982{col 26}{space 2} .1844081{col 37}{space 1} 147.77{col 46}{space 3}0.000{col 54}{space 4} 26.88823{col 67}{space 3} 27.61141 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {p 0 7}{space 1}{text:( 1)}{space 1} {res}5.physact + _cons = 0{p_end} {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmi{col 14}{c |} Coef.{col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}(1) {c |}{col 14}{res}{space 2} 26.49941{col 26}{space 2} .3049875{col 37}{space 1} 86.89{col 46}{space 3}0.000{col 54}{space 4} 25.90138{col 67}{space 3} 27.09744 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. * again, using margins . margins physact {res} {txt}Adjusted predictions{col 51}Number of obs{col 67}= {res} 2758 {txt}Model VCE{col 14}: {res}OLS {txt}{p2colset 1 14 16 2}{...} {p2col:Expression}:{space 1}{res:Linear prediction, predict()}{p_end} {p2colreset}{...} {res}{txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 23}{c |}{col 35} Delta-method {col 23}{c |} Margin{col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 14}physact {c |} {space 4}much less active {c |}{col 23}{res}{space 2} 30.86719{col 35}{space 2} .3810787{col 46}{space 1} 81.00{col 55}{space 3}0.000{col 63}{space 4} 30.11996{col 76}{space 3} 31.61442 {txt}somewhat less active {c |}{col 23}{res}{space 2} 30.34394{col 35}{space 2} .2381172{col 46}{space 1} 127.43{col 55}{space 3}0.000{col 63}{space 4} 29.87704{col 76}{space 3} 30.81085 {txt}{space 5}about as active {c |}{col 23}{res}{space 2} 29.03165{col 35}{space 2} .1761806{col 46}{space 1} 164.78{col 55}{space 3}0.000{col 63}{space 4} 28.68619{col 76}{space 3} 29.37711 {txt}somewhat more active {c |}{col 23}{res}{space 2} 27.24982{col 35}{space 2} .1844081{col 46}{space 1} 147.77{col 55}{space 3}0.000{col 63}{space 4} 26.88823{col 76}{space 3} 27.61141 {txt}{space 4}much more active {c |}{col 23}{res}{space 2} 26.49941{col 35}{space 2} .3049875{col 46}{space 1} 86.89{col 55}{space 3}0.000{col 63}{space 4} 25.90138{col 76}{space 3} 27.09744 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. . * test for heterogeneity . testparm i.physact {p 0 7}{space 1}{text:( 1)}{space 1} {res}2.physact = 0{p_end} {p 0 7}{space 1}{text:( 2)}{space 1} 3.physact = 0{p_end} {p 0 7}{space 1}{text:( 3)}{space 1} 4.physact = 0{p_end} {p 0 7}{space 1}{text:( 4)}{space 1} 5.physact = 0{p_end} {txt} F( 4, 2753) ={res} 49.01 {txt}{col 13}Prob > F ={res} 0.0000 {txt} {com}. * test for linear trend . contrast q(1).physact, noeffects {res} {txt}Contrasts of marginal linear predictions {txt}{p2colset 1 14 16 2}{...} {p2col:Margins}:{space 1}{res:asbalanced}{p_end} {p2colreset}{...} {col 1}{text}{hline 13}{c TT}{hline 11}{hline 12}{hline 11} {col 14}{text}{c |} df{col 26} F{col 38} P>F {col 1}{text}{hline 13}{c +}{hline 11}{hline 12}{hline 11} {space 5}physact {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 134.09{col 38}{space 2} 0.0000 {col 14}{text}{c |} {col 1}{text} Denominator{col 14}{c |}{result}{space 2} 2753 {col 1}{text}{hline 13}{c BT}{hline 11}{hline 12}{hline 11} {com}. * test for departure from linear trend . contrast q(2/4).physact, noeffects {res} {txt}Contrasts of marginal linear predictions {txt}{p2colset 1 14 16 2}{...} {p2col:Margins}:{space 1}{res:asbalanced}{p_end} {p2colreset}{...} {col 1}{text}{hline 13}{c TT}{hline 11}{hline 12}{hline 11} {col 14}{text}{c |} df{col 26} F{col 38} P>F {col 1}{text}{hline 13}{c +}{hline 11}{hline 12}{hline 11} {space 5}physact {c |} (quadratic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 0.73{col 38}{space 2} 0.3927 {txt} (cubic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 5.51{col 38}{space 2} 0.0189 {txt} (quartic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 0.50{col 38}{space 2} 0.4808 {col 1}{text} Joint {col 14}{c |}{result}{space 2} 3{col 26}{space 3} 2.45{col 38}{space 2} 0.0615 {col 14}{text}{c |} {col 1}{text} Denominator{col 14}{c |}{result}{space 2} 2753 {col 1}{text}{hline 13}{c BT}{hline 11}{hline 12}{hline 11} {com}. . * repeat with adjustment for age, smoking, and alcohol use . reg bmi i.physact age10 smoking drnkspwk {txt}Source {c |} SS df MS Number of obs ={res} 2758 {txt}{hline 13}{char +}{hline 30} F( 7, 2750) ={res} 51.75 {txt} Model {char |} {res} 9770.72238 7 1395.81748 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 74168.7181 2750 26.9704429 {txt}R-squared = {res} 0.1164 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.1142 {txt} Total {char |} {res} 83939.4405 2757 30.4459342 {txt}Root MSE = {res} 5.1933 {txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmi{col 23}{c |} Coef.{col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 14}physact {c |} somewhat less active {c |}{col 23}{res}{space 2}-.6280119{col 35}{space 2} .4376396{col 46}{space 1} -1.43{col 55}{space 3}0.151{col 63}{space 4}-1.486147{col 76}{space 3} .2301235 {txt}{space 5}about as active {c |}{col 23}{res}{space 2}-1.802389{col 35}{space 2} .4101722{col 46}{space 1} -4.39{col 55}{space 3}0.000{col 63}{space 4}-2.606665{col 76}{space 3}-.9981121 {txt}somewhat more active {c |}{col 23}{res}{space 2}-3.490371{col 35}{space 2} .4154996{col 46}{space 1} -8.40{col 55}{space 3}0.000{col 63}{space 4}-4.305094{col 76}{space 3}-2.675648 {txt}{space 4}much more active {c |}{col 23}{res}{space 2}-4.104422{col 35}{space 2} .4783847{col 46}{space 1} -8.58{col 55}{space 3}0.000{col 63}{space 4}-5.042452{col 76}{space 3}-3.166392 {txt}{space 21} {c |} {space 16}age10 {c |}{col 23}{res}{space 2}-1.290458{col 35}{space 2} .1536594{col 46}{space 1} -8.40{col 55}{space 3}0.000{col 63}{space 4}-1.591757{col 76}{space 3}-.9891585 {txt}{space 14}smoking {c |}{col 23}{res}{space 2}-2.574357{col 35}{space 2} .3006797{col 46}{space 1} -8.56{col 55}{space 3}0.000{col 63}{space 4}-3.163938{col 76}{space 3}-1.984776 {txt}{space 13}drnkspwk {c |}{col 23}{res}{space 2}-.1580992{col 35}{space 2} .0271912{col 46}{space 1} -5.81{col 55}{space 3}0.000{col 63}{space 4}-.2114164{col 76}{space 3}-.1047821 {txt}{space 16}_cons {c |}{col 23}{res}{space 2} 39.95839{col 35}{space 2} 1.077797{col 46}{space 1} 37.07{col 55}{space 3}0.000{col 63}{space 4} 37.84502{col 76}{space 3} 42.07177 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. * compute marginal mean BMI at each level of physact, . * averaging over other predictors . margins physact {res} {txt}Predictive margins{col 51}Number of obs{col 67}= {res} 2758 {txt}Model VCE{col 14}: {res}OLS {txt}{p2colset 1 14 16 2}{...} {p2col:Expression}:{space 1}{res:Linear prediction, predict()}{p_end} {p2colreset}{...} {res}{txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 23}{c |}{col 35} Delta-method {col 23}{c |} Margin{col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 14}physact {c |} {space 4}much less active {c |}{col 23}{res}{space 2} 30.80748{col 35}{space 2} .3726344{col 46}{space 1} 82.67{col 55}{space 3}0.000{col 63}{space 4} 30.0768{col 76}{space 3} 31.53815 {txt}somewhat less active {c |}{col 23}{res}{space 2} 30.17946{col 35}{space 2} .2333813{col 46}{space 1} 129.31{col 55}{space 3}0.000{col 63}{space 4} 29.72184{col 76}{space 3} 30.63708 {txt}{space 5}about as active {c |}{col 23}{res}{space 2} 29.00509{col 35}{space 2} .1715376{col 46}{space 1} 169.09{col 55}{space 3}0.000{col 63}{space 4} 28.66873{col 76}{space 3} 29.34144 {txt}somewhat more active {c |}{col 23}{res}{space 2} 27.3171{col 35}{space 2} .18039{col 46}{space 1} 151.43{col 55}{space 3}0.000{col 63}{space 4} 26.96339{col 76}{space 3} 27.67082 {txt}{space 4}much more active {c |}{col 23}{res}{space 2} 26.70305{col 35}{space 2} .2978692{col 46}{space 1} 89.65{col 55}{space 3}0.000{col 63}{space 4} 26.11898{col 76}{space 3} 27.28712 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. * verifiy results from last command . gen y1 = _b[_cons] + _b[1.physact]*1 + _b[age10 ]*age10 + _b[smoking]*smoking + _b[drnkspwk]*drnkspwk if e(sample) {txt}(5 missing values generated) {com}. gen y2 = _b[_cons] + _b[2.physact]*1 + _b[age10 ]*age10 + _b[smoking]*smoking + _b[drnkspwk]*drnkspwk if e(sample) {txt}(5 missing values generated) {com}. gen y3 = _b[_cons] + _b[3.physact]*1 + _b[age10 ]*age10 + _b[smoking]*smoking + _b[drnkspwk]*drnkspwk if e(sample) {txt}(5 missing values generated) {com}. gen y4 = _b[_cons] + _b[4.physact]*1 + _b[age10 ]*age10 + _b[smoking]*smoking + _b[drnkspwk]*drnkspwk if e(sample) {txt}(5 missing values generated) {com}. gen y5 = _b[_cons] + _b[5.physact]*1 + _b[age10 ]*age10 + _b[smoking]*smoking + _b[drnkspwk]*drnkspwk if e(sample) {txt}(5 missing values generated) {com}. summ y1 y2 y3 y4 y5 {txt} Variable {c |} Obs Mean Std. Dev. Min Max {hline 13}{c +}{hline 56} {space 10}y1 {c |}{res} 2758 30.80747 1.237514 22.46061 34.24349 {txt}{space 10}y2 {c |}{res} 2758 30.17946 1.237514 21.83259 33.61548 {txt}{space 10}y3 {c |}{res} 2758 29.00509 1.237514 20.65822 32.4411 {txt}{space 10}y4 {c |}{res} 2758 27.3171 1.237514 18.97024 30.75312 {txt}{space 10}y5 {c |}{res} 2758 26.70305 1.237514 18.35618 30.13907 {txt} {com}. . * compute marginal mean BMI at each level of physact, . * with other predictors fixed at mean values . margins physact, atmeans {res} {txt}Adjusted predictions{col 51}Number of obs{col 67}= {res} 2758 {txt}Model VCE{col 14}: {res}OLS {txt}{p2colset 1 14 16 2}{...} {p2col:Expression}:{space 1}{res:Linear prediction, predict()}{p_end} {p2colreset}{...} {txt}{p2colset 1 14 16 2}{...} {p2col:at}:{space 1}{res:{txt:1.physact}{space 7}{txt:=} {space 4}.071066 {txt:(mean)}}{p_end} {p2colreset}{...} {txt}{p2colset 1 14 16 2}{...} {p2col: }{space 2}{res:{txt:2.physact}{space 7}{txt:=} {space 4}.182016 {txt:(mean)}}{p_end} {p2colreset}{...} {txt}{p2colset 1 14 16 2}{...} {p2col: }{space 2}{res:{txt:3.physact}{space 7}{txt:=} {space 3}.3324873 {txt:(mean)}}{p_end} {p2colreset}{...} {txt}{p2colset 1 14 16 2}{...} {p2col: }{space 2}{res:{txt:4.physact}{space 7}{txt:=} {space 3}.3034808 {txt:(mean)}}{p_end} {p2colreset}{...} {txt}{p2colset 1 14 16 2}{...} {p2col: }{space 2}{res:{txt:5.physact}{space 7}{txt:=} {space 5}.11095 {txt:(mean)}}{p_end} {p2colreset}{...} {txt}{p2colset 1 14 16 2}{...} {p2col: }{space 2}{res:{txt:age10}{space 11}{txt:=} {space 3}6.665228 {txt:(mean)}}{p_end} {p2colreset}{...} {txt}{p2colset 1 14 16 2}{...} {p2col: }{space 2}{res:{txt:smoking}{space 9}{txt:=} {space 3}.1301668 {txt:(mean)}}{p_end} {p2colreset}{...} {txt}{p2colset 1 14 16 2}{...} {p2col: }{space 2}{res:{txt:drnkspwk}{space 8}{txt:=} {space 3}1.357542 {txt:(mean)}}{p_end} {p2colreset}{...} {res}{txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 23}{c |}{col 35} Delta-method {col 23}{c |} Margin{col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 14}physact {c |} {space 4}much less active {c |}{col 23}{res}{space 2} 30.80748{col 35}{space 2} .3726344{col 46}{space 1} 82.67{col 55}{space 3}0.000{col 63}{space 4} 30.0768{col 76}{space 3} 31.53815 {txt}somewhat less active {c |}{col 23}{res}{space 2} 30.17946{col 35}{space 2} .2333813{col 46}{space 1} 129.31{col 55}{space 3}0.000{col 63}{space 4} 29.72184{col 76}{space 3} 30.63708 {txt}{space 5}about as active {c |}{col 23}{res}{space 2} 29.00509{col 35}{space 2} .1715376{col 46}{space 1} 169.09{col 55}{space 3}0.000{col 63}{space 4} 28.66873{col 76}{space 3} 29.34144 {txt}somewhat more active {c |}{col 23}{res}{space 2} 27.3171{col 35}{space 2} .18039{col 46}{space 1} 151.43{col 55}{space 3}0.000{col 63}{space 4} 26.96339{col 76}{space 3} 27.67082 {txt}{space 4}much more active {c |}{col 23}{res}{space 2} 26.70305{col 35}{space 2} .2978693{col 46}{space 1} 89.65{col 55}{space 3}0.000{col 63}{space 4} 26.11898{col 76}{space 3} 27.28712 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. * verifiy results from last command . * first generate mean values for predictors in estimation sample . egen m_age10 = mean(age10) if e(sample) {txt}(5 missing values generated) {com}. egen m_smoking = mean(smoking) if e(sample) {txt}(5 missing values generated) {com}. egen m_drnkspwk = mean(drnkspwk) if e(sample) {txt}(5 missing values generated) {com}. gen z1 = _b[_cons] + _b[1.physact]*1 + _b[age10 ]*m_age10 + _b[smoking]*m_smoking + _b[drnkspwk]*m_drnkspwk if e(sample) {txt}(5 missing values generated) {com}. gen z2 = _b[_cons] + _b[2.physact]*1 + _b[age10 ]*m_age10 + _b[smoking]*m_smoking + _b[drnkspwk]*m_drnkspwk if e(sample) {txt}(5 missing values generated) {com}. gen z3 = _b[_cons] + _b[3.physact]*1 + _b[age10 ]*m_age10 + _b[smoking]*m_smoking + _b[drnkspwk]*m_drnkspwk if e(sample) {txt}(5 missing values generated) {com}. gen z4 = _b[_cons] + _b[4.physact]*1 + _b[age10 ]*m_age10 + _b[smoking]*m_smoking + _b[drnkspwk]*m_drnkspwk if e(sample) {txt}(5 missing values generated) {com}. gen z5 = _b[_cons] + _b[5.physact]*1 + _b[age10 ]*m_age10 + _b[smoking]*m_smoking + _b[drnkspwk]*m_drnkspwk if e(sample) {txt}(5 missing values generated) {com}. summ z1 z2 z3 z4 z5 {txt} Variable {c |} Obs Mean Std. Dev. Min Max {hline 13}{c +}{hline 56} {space 10}z1 {c |}{res} 2758 30.80748 0 30.80748 30.80748 {txt}{space 10}z2 {c |}{res} 2758 30.17946 0 30.17946 30.17946 {txt}{space 10}z3 {c |}{res} 2758 29.00509 0 29.00509 29.00509 {txt}{space 10}z4 {c |}{res} 2758 27.3171 0 27.3171 27.3171 {txt}{space 10}z5 {c |}{res} 2758 26.70305 0 26.70305 26.70305 {txt} {com}. * check that the differences between the adjusted marginal means . * (relative to the reference activity level) equal the estimated regression coefficients . margins, dydx(physact) {res} {txt}Average marginal effects{col 51}Number of obs{col 67}= {res} 2758 {txt}Model VCE{col 14}: {res}OLS {txt}{p2colset 1 14 16 2}{...} {p2col:Expression}:{space 1}{res:Linear prediction, predict()}{p_end} {p2colreset}{...} {txt}{p2colset 1 14 16 2}{...} {p2col:dy/dx w.r.t.}:{space 1}{res:2.physact 3.physact 4.physact 5.physact}{p_end} {p2colreset}{...} {res}{txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 23}{c |}{col 35} Delta-method {col 23}{c |} dy/dx{col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 14}physact {c |} somewhat less active {c |}{col 23}{res}{space 2}-.6280119{col 35}{space 2} .4376396{col 46}{space 1} -1.43{col 55}{space 3}0.151{col 63}{space 4}-1.486147{col 76}{space 3} .2301235 {txt}{space 5}about as active {c |}{col 23}{res}{space 2}-1.802389{col 35}{space 2} .4101722{col 46}{space 1} -4.39{col 55}{space 3}0.000{col 63}{space 4}-2.606665{col 76}{space 3}-.9981121 {txt}somewhat more active {c |}{col 23}{res}{space 2}-3.490371{col 35}{space 2} .4154996{col 46}{space 1} -8.40{col 55}{space 3}0.000{col 63}{space 4}-4.305094{col 76}{space 3}-2.675648 {txt}{space 4}much more active {c |}{col 23}{res}{space 2}-4.104422{col 35}{space 2} .4783847{col 46}{space 1} -8.58{col 55}{space 3}0.000{col 63}{space 4}-5.042452{col 76}{space 3}-3.166392 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {p 0 6 0 87}Note: dy/dx for factor levels is the discrete change from the base level.{txt}{p_end} {res}{txt} {com}. . * test for heterogeneity . testparm i.physact {p 0 7}{space 1}{text:( 1)}{space 1} {res}2.physact = 0{p_end} {p 0 7}{space 1}{text:( 2)}{space 1} 3.physact = 0{p_end} {p 0 7}{space 1}{text:( 3)}{space 1} 4.physact = 0{p_end} {p 0 7}{space 1}{text:( 4)}{space 1} 5.physact = 0{p_end} {txt} F( 4, 2750) ={res} 43.28 {txt}{col 13}Prob > F ={res} 0.0000 {txt} {com}. * test for linear trend . contrast q(1).physact, noeffects {res} {txt}Contrasts of marginal linear predictions {txt}{p2colset 1 14 16 2}{...} {p2col:Margins}:{space 1}{res:asbalanced}{p_end} {p2colreset}{...} {col 1}{text}{hline 13}{c TT}{hline 11}{hline 12}{hline 11} {col 14}{text}{c |} df{col 26} F{col 38} P>F {col 1}{text}{hline 13}{c +}{hline 11}{hline 12}{hline 11} {space 5}physact {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 120.97{col 38}{space 2} 0.0000 {col 14}{text}{c |} {col 1}{text} Denominator{col 14}{c |}{result}{space 2} 2750 {col 1}{text}{hline 13}{c BT}{hline 11}{hline 12}{hline 11} {com}. * test for departure from linear trend . contrast q(2/4).physact, noeffects {res} {txt}Contrasts of marginal linear predictions {txt}{p2colset 1 14 16 2}{...} {p2col:Margins}:{space 1}{res:asbalanced}{p_end} {p2colreset}{...} {col 1}{text}{hline 13}{c TT}{hline 11}{hline 12}{hline 11} {col 14}{text}{c |} df{col 26} F{col 38} P>F {col 1}{text}{hline 13}{c +}{hline 11}{hline 12}{hline 11} {space 5}physact {c |} (quadratic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 0.21{col 38}{space 2} 0.6447 {txt} (cubic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 4.60{col 38}{space 2} 0.0321 {txt} (quartic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 0.91{col 38}{space 2} 0.3406 {col 1}{text} Joint {col 14}{c |}{result}{space 2} 3{col 26}{space 3} 2.21{col 38}{space 2} 0.0852 {col 14}{text}{c |} {col 1}{text} Denominator{col 14}{c |}{result}{space 2} 2750 {col 1}{text}{hline 13}{c BT}{hline 11}{hline 12}{hline 11} {com}. . * models using log of creatinine level as outcome and predictor . regress lncreat bmi age, eform("exp(beta)") {txt}Source {c |} SS df MS Number of obs ={res} 2756 {txt}{hline 13}{char +}{hline 30} F( 2, 2753) ={res} 55.00 {txt} Model {char |} {res} 4.76569402 2 2.38284701 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 119.265116 2753 .043321873 {txt}R-squared = {res} 0.0384 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.0377 {txt} Total {char |} {res} 124.03081 2755 .045020258 {txt}Root MSE = {res} .20814 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} exp(beta){col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}bmi {c |}{col 14}{res}{space 2} 1.003308{col 26}{space 2} .0007303{col 37}{space 1} 4.54{col 46}{space 3}0.000{col 54}{space 4} 1.001877{col 67}{space 3} 1.004741 {txt}{space 9}age {c |}{col 14}{res}{space 2} 1.006093{col 26}{space 2} .0006076{col 37}{space 1} 10.06{col 46}{space 3}0.000{col 54}{space 4} 1.004902{col 67}{space 3} 1.007285 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .6405172{col 26}{space 2} .0309547{col 37}{space 1} -9.22{col 46}{space 3}0.000{col 54}{space 4} .5826076{col 67}{space 3} .704183 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. nlcom 100*(exp(_b[bmi])-1) {txt}_nl_1: {res}100*(exp(_b[bmi])-1) {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} Coef.{col 26} Std. Err.{col 38} z{col 46} P>|z|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 7}_nl_1 {c |}{col 14}{res}{space 2} .330835{col 26}{space 2} .0730259{col 37}{space 1} 4.53{col 46}{space 3}0.000{col 54}{space 4} .1877068{col 67}{space 3} .4739632 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. regress sbp lncreat age diabetes {txt}Source {c |} SS df MS Number of obs ={res} 2761 {txt}{hline 13}{char +}{hline 30} F( 3, 2757) ={res} 61.70 {txt} Model {char |} {res} 62724.9665 3 20908.3222 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 934341.036 2757 338.897728 {txt}R-squared = {res} 0.0629 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.0619 {txt} Total {char |} {res} 997066.003 2760 361.255798 {txt}Root MSE = {res} 18.409 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} sbp{col 14}{c |} Coef.{col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 5}lncreat {c |}{col 14}{res}{space 2} 9.211717{col 26}{space 2} 1.682269{col 37}{space 1} 5.48{col 46}{space 3}0.000{col 54}{space 4} 5.913081{col 67}{space 3} 12.51035 {txt}{space 9}age {c |}{col 14}{res}{space 2} .444083{col 26}{space 2} .0536661{col 37}{space 1} 8.27{col 46}{space 3}0.000{col 54}{space 4} .3388531{col 67}{space 3} .5493129 {txt}{space 4}diabetes {c |}{col 14}{res}{space 2} 6.426345{col 26}{space 2} .8007529{col 37}{space 1} 8.03{col 46}{space 3}0.000{col 54}{space 4} 4.856209{col 67}{space 3} 7.996481 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} 103.2765{col 26}{space 2} 3.600996{col 37}{space 1} 28.68{col 46}{space 3}0.000{col 54}{space 4} 96.21558{col 67}{space 3} 110.3374 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. nlcom _b[lncreat]*log(1.25) {txt}_nl_1: {res}_b[lncreat]*log(1.25) {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} sbp{col 14}{c |} Coef.{col 26} Std. Err.{col 38} z{col 46} P>|z|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 7}_nl_1 {c |}{col 14}{res}{space 2} 2.055535{col 26}{space 2} .3753876{col 37}{space 1} 5.48{col 46}{space 3}0.000{col 54}{space 4} 1.319789{col 67}{space 3} 2.791281 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. . log close {txt}name: {res} {txt}log: {res}/Users/steve/Documents/teaching/c2015/biostat208/labs/lab3/lab3.smcl {txt}log type: {res}smcl {txt}closed on: {res}21 Jan 2015, 17:50:45 {txt}{.-} {smcl} {txt}{sf}{ul off}