{smcl} {com}{sf}{ul off}{txt}{.-} name: {res} {txt}log: {res}/Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/lab6.smcl {txt}log type: {res}smcl {txt}opened on: {res}10 Feb 2015, 08:37:08 {txt} {com}. use lab6, clear {txt} {com}. . * univariate linearity . lowess bmd age, name(linearity, replace) {res}{txt} {com}. graph export linearity.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/linearity.pdf written in PDF format) {com}. . * multivariate linearity . reg bmd age weight {txt}Source {c |} SS df MS Number of obs ={res} 278 {txt}{hline 13}{char +}{hline 30} F( 2, 275) ={res} 54.77 {txt} Model {char |} {res} 1.48243732 2 .741218662 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.72190651 275 .013534205 {txt}R-squared = {res} 0.2848 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.2796 {txt} Total {char |} {res} 5.20434383 277 .018788245 {txt}Root MSE = {res} .11634 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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}age {c |}{col 14}{res}{space 2}-.0049417{col 26}{space 2} .0015401{col 37}{space 1} -3.21{col 46}{space 3}0.001{col 54}{space 4}-.0079736{col 67}{space 3}-.0019099 {txt}{space 6}weight {c |}{col 14}{res}{space 2} .0047503{col 26}{space 2} .0005353{col 37}{space 1} 8.87{col 46}{space 3}0.000{col 54}{space 4} .0036964{col 67}{space 3} .0058041 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .7925524{col 26}{space 2} .1347116{col 37}{space 1} 5.88{col 46}{space 3}0.000{col 54}{space 4} .5273553{col 67}{space 3} 1.057749 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. cprplot weight, lowess name(cprplot1, replace) {res}{txt} {com}. graph export cprplot1.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/cprplot1.pdf written in PDF format) {com}. quietly adjust age, by(weight) gen(fitted1) {txt} {com}. . regress bmd age lweight {txt}Source {c |} SS df MS Number of obs ={res} 278 {txt}{hline 13}{char +}{hline 30} F( 2, 275) ={res} 61.64 {txt} Model {char |} {res} 1.61096241 2 .805481207 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.59338142 275 .013066842 {txt}R-squared = {res} 0.3095 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.3045 {txt} Total {char |} {res} 5.20434383 277 .018788245 {txt}Root MSE = {res} .11431 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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}age {c |}{col 14}{res}{space 2}-.0047296{col 26}{space 2} .0015137{col 37}{space 1} -3.12{col 46}{space 3}0.002{col 54}{space 4}-.0077094{col 67}{space 3}-.0017497 {txt}{space 5}lweight {c |}{col 14}{res}{space 2} .3483217{col 26}{space 2} .0364352{col 37}{space 1} 9.56{col 46}{space 3}0.000{col 54}{space 4} .2765944{col 67}{space 3} .420049 {txt}{space 7}_cons {c |}{col 14}{res}{space 2}-.3640786{col 26}{space 2} .2156111{col 37}{space 1} -1.69{col 46}{space 3}0.092{col 54}{space 4}-.7885367{col 67}{space 3} .0603794 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. cprplot lweight, lowess name(cprplot2, replace) {res}{txt} {com}. nlcom _b[lweight]*log(1.1) {txt}_nl_1: {res}_b[lweight]*log(1.1) {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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} .0331986{col 26}{space 2} .0034726{col 37}{space 1} 9.56{col 46}{space 3}0.000{col 54}{space 4} .0263923{col 67}{space 3} .0400049 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. graph export cprplot2.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/cprplot2.pdf written in PDF format) {com}. quietly adjust age, by(weight) gen(fitted2) {txt} {com}. . regress bmd age weight weight2 {txt}Source {c |} SS df MS Number of obs ={res} 278 {txt}{hline 13}{char +}{hline 30} F( 3, 274) ={res} 43.38 {txt} Model {char |} {res} 1.67578732 3 .558595772 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.52855652 274 .012877943 {txt}R-squared = {res} 0.3220 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.3146 {txt} Total {char |} {res} 5.20434383 277 .018788245 {txt}Root MSE = {res} .11348 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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}age {c |}{col 14}{res}{space 2}-.0047303{col 26}{space 2} .0015033{col 37}{space 1} -3.15{col 46}{space 3}0.002{col 54}{space 4}-.0076897{col 67}{space 3}-.0017709 {txt}{space 6}weight {c |}{col 14}{res}{space 2} .0182735{col 26}{space 2} .0035289{col 37}{space 1} 5.18{col 46}{space 3}0.000{col 54}{space 4} .0113263{col 67}{space 3} .0252207 {txt}{space 5}weight2 {c |}{col 14}{res}{space 2}-.0000925{col 26}{space 2} .0000239{col 37}{space 1} -3.87{col 46}{space 3}0.000{col 54}{space 4}-.0001395{col 67}{space 3}-.0000455 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .3012021{col 26}{space 2} .1826122{col 37}{space 1} 1.65{col 46}{space 3}0.100{col 54}{space 4}-.0582992{col 67}{space 3} .6607034 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. quietly adjust age, gen(fitted3) {txt} {com}. predict residuals2, resid {txt} {com}. rvpplot weight, yline(0) addplot(lowess residuals2 weight) name(rvpplot3, replace) {res}{txt} {com}. graph export rvpplot3.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/rvpplot3.pdf written in PDF format) {com}. . mkspline wt = weight, cubic {txt} {com}. regress bmd age wt1-wt4 {txt}Source {c |} SS df MS Number of obs ={res} 278 {txt}{hline 13}{char +}{hline 30} F( 5, 272) ={res} 27.20 {txt} Model {char |} {res} 1.73493728 5 .346987456 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.46940655 272 .012755171 {txt}R-squared = {res} 0.3334 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.3211 {txt} Total {char |} {res} 5.20434383 277 .018788245 {txt}Root MSE = {res} .11294 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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}age {c |}{col 14}{res}{space 2}-.0046327{col 26}{space 2} .0014971{col 37}{space 1} -3.09{col 46}{space 3}0.002{col 54}{space 4}-.0075801{col 67}{space 3}-.0016852 {txt}{space 9}wt1 {c |}{col 14}{res}{space 2} .0127171{col 26}{space 2} .0027237{col 37}{space 1} 4.67{col 46}{space 3}0.000{col 54}{space 4} .0073548{col 67}{space 3} .0180794 {txt}{space 9}wt2 {c |}{col 14}{res}{space 2}-.0380388{col 26}{space 2} .0232925{col 37}{space 1} -1.63{col 46}{space 3}0.104{col 54}{space 4}-.0838954{col 67}{space 3} .0078177 {txt}{space 9}wt3 {c |}{col 14}{res}{space 2} .1268726{col 26}{space 2} .099673{col 37}{space 1} 1.27{col 46}{space 3}0.204{col 54}{space 4} -.069356{col 67}{space 3} .3231011 {txt}{space 9}wt4 {c |}{col 14}{res}{space 2}-.1337551{col 26}{space 2} .1235098{col 37}{space 1} -1.08{col 46}{space 3}0.280{col 54}{space 4}-.3769117{col 67}{space 3} .1094015 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .3306817{col 26}{space 2} .193215{col 37}{space 1} 1.71{col 46}{space 3}0.088{col 54}{space 4}-.0497053{col 67}{space 3} .7110687 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. quietly adjust age, by(weight) gen(fitted4) {txt} {com}. . twoway (scatter bmd weight, msize(small)) /// > (line fitted1 weight, sort lpattern(solid) lwidth(medthick)) /// > (line fitted2 weight, sort lpattern(dash_dot) lwidth(thick)) /// > (line fitted3 weight, sort lpattern(longdash) lwidth(thick)) /// > (line fitted4 weight, sort lpattern(shortdash) lwidth(thick)), /// > legend(order(2 "Linear" 3 "Log" 4 "Quadratic" 5 "Cubic spline") rows(2)) /// > name(bmdfits, replace) {res}{txt} {com}. graph export bmdfits.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/bmdfits.pdf written in PDF format) {com}. drop fitted* {txt} {com}. . * normality of residuals . reg bmd age weight weight2 {txt}Source {c |} SS df MS Number of obs ={res} 278 {txt}{hline 13}{char +}{hline 30} F( 3, 274) ={res} 43.38 {txt} Model {char |} {res} 1.67578732 3 .558595772 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.52855652 274 .012877943 {txt}R-squared = {res} 0.3220 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.3146 {txt} Total {char |} {res} 5.20434383 277 .018788245 {txt}Root MSE = {res} .11348 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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}age {c |}{col 14}{res}{space 2}-.0047303{col 26}{space 2} .0015033{col 37}{space 1} -3.15{col 46}{space 3}0.002{col 54}{space 4}-.0076897{col 67}{space 3}-.0017709 {txt}{space 6}weight {c |}{col 14}{res}{space 2} .0182735{col 26}{space 2} .0035289{col 37}{space 1} 5.18{col 46}{space 3}0.000{col 54}{space 4} .0113263{col 67}{space 3} .0252207 {txt}{space 5}weight2 {c |}{col 14}{res}{space 2}-.0000925{col 26}{space 2} .0000239{col 37}{space 1} -3.87{col 46}{space 3}0.000{col 54}{space 4}-.0001395{col 67}{space 3}-.0000455 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .3012021{col 26}{space 2} .1826122{col 37}{space 1} 1.65{col 46}{space 3}0.100{col 54}{space 4}-.0582992{col 67}{space 3} .6607034 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. predict bmdresid, resid {txt} {com}. qnorm bmdresid, name(qqplot1, replace) {res}{txt} {com}. graph export qqplot1.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/qqplot1.pdf written in PDF format) {com}. kdensity bmdresid, normal {res}{txt} {com}. graph export kdplot1.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/kdplot1.pdf written in PDF format) {com}. . reg eeu age poorhlth gaitspd {txt}Source {c |} SS df MS Number of obs ={res} 277 {txt}{hline 13}{char +}{hline 30} F( 3, 273) ={res} 4.22 {txt} Model {char |} {res} 98.2991326 3 32.7663775 {txt}Prob > F = {res} 0.0061 {txt}Residual {char |} {res} 2118.21339 273 7.7590234 {txt}R-squared = {res} 0.0443 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.0338 {txt} Total {char |} {res} 2216.51252 276 8.03084246 {txt}Root MSE = {res} 2.7855 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} eeu{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}age {c |}{col 14}{res}{space 2}-.0255973{col 26}{space 2} .0393144{col 37}{space 1} -0.65{col 46}{space 3}0.516{col 54}{space 4}-.1029952{col 67}{space 3} .0518006 {txt}{space 4}poorhlth {c |}{col 14}{res}{space 2} -.898035{col 26}{space 2} .4189794{col 37}{space 1} -2.14{col 46}{space 3}0.033{col 54}{space 4}-1.722876{col 67}{space 3}-.0731938 {txt}{space 5}gaitspd {c |}{col 14}{res}{space 2} 1.647421{col 26}{space 2} .8897152{col 37}{space 1} 1.85{col 46}{space 3}0.065{col 54}{space 4}-.1041537{col 67}{space 3} 3.398996 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} 3.414444{col 26}{space 2} 3.538559{col 37}{space 1} 0.96{col 46}{space 3}0.335{col 54}{space 4}-3.551888{col 67}{space 3} 10.38078 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. predict eeuresid, res {txt}(1 missing value generated) {com}. qnorm eeuresid, name(qqplot2, replace) {res}{txt} {com}. graph export qqplot2.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/qqplot2.pdf written in PDF format) {com}. . replace eeu = eeu+0.01 {txt}(278 real changes made) {com}. qladder eeu, name(qladder, replace) {res}{txt} {com}. graph export qladder.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/qladder.pdf written in PDF format) {com}. . gen ln_eeu = log(eeu) {txt} {com}. reg ln_eeu age poorhlth gaitspd {txt}Source {c |} SS df MS Number of obs ={res} 277 {txt}{hline 13}{char +}{hline 30} F( 3, 273) ={res} 8.27 {txt} Model {char |} {res} 25.8655573 3 8.62185242 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 284.570802 273 1.04238389 {txt}R-squared = {res} 0.0833 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.0732 {txt} Total {char |} {res} 310.43636 276 1.12476942 {txt}Root MSE = {res} 1.021 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} ln_eeu{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}age {c |}{col 14}{res}{space 2} -.008435{col 26}{space 2} .0144099{col 37}{space 1} -0.59{col 46}{space 3}0.559{col 54}{space 4}-.0368037{col 67}{space 3} .0199337 {txt}{space 4}poorhlth {c |}{col 14}{res}{space 2}-.3544198{col 26}{space 2} .1535688{col 37}{space 1} -2.31{col 46}{space 3}0.022{col 54}{space 4}-.6567494{col 67}{space 3}-.0520902 {txt}{space 5}gaitspd {c |}{col 14}{res}{space 2} 1.06321{col 26}{space 2} .3261079{col 37}{space 1} 3.26{col 46}{space 3}0.001{col 54}{space 4} .4212045{col 67}{space 3} 1.705216 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .3000781{col 26}{space 2} 1.29699{col 37}{space 1} 0.23{col 46}{space 3}0.817{col 54}{space 4}-2.253296{col 67}{space 3} 2.853452 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. predict ln_eeuresid, res {txt}(1 missing value generated) {com}. qnorm ln_eeuresid, name(qqplot3, replace) {res}{txt} {com}. graph export qqplot3.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/qqplot3.pdf written in PDF format) {com}. . * constant variance . rvfplot, name(rvfplot1, replace) {res}{txt} {com}. graph export rvfplot1.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/rvfplot1.pdf written in PDF format) {com}. rvpplot age, name(rvpplot1, replace) {res}{txt} {com}. graph export rvpplot1.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/rvpplot1.pdf written in PDF format) {com}. rvpplot gaitspd, name(rvpplot2, replace) {res}{txt} {com}. graph export rvpplot2.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/rvpplot2.pdf written in PDF format) {com}. table poorhlth, c(n ln_eeuresid sd ln_eeuresid) {txt}{hline 10}{c TT}{hline 27} poor {c |} health by {c |} self-repo {c |} rt {c |} N(ln_eeu~d) sd(ln_eeu~d) {hline 10}{c +}{hline 27} no {c |} {res}217 .9795251 {txt}yes {c |} {res}60 1.144814 {txt}{hline 10}{c BT}{hline 27} {com}. . * leverage and influence . reg bmd age lweight {txt}Source {c |} SS df MS Number of obs ={res} 278 {txt}{hline 13}{char +}{hline 30} F( 2, 275) ={res} 61.64 {txt} Model {char |} {res} 1.61096241 2 .805481207 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.59338142 275 .013066842 {txt}R-squared = {res} 0.3095 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.3045 {txt} Total {char |} {res} 5.20434383 277 .018788245 {txt}Root MSE = {res} .11431 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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}age {c |}{col 14}{res}{space 2}-.0047296{col 26}{space 2} .0015137{col 37}{space 1} -3.12{col 46}{space 3}0.002{col 54}{space 4}-.0077094{col 67}{space 3}-.0017497 {txt}{space 5}lweight {c |}{col 14}{res}{space 2} .3483217{col 26}{space 2} .0364352{col 37}{space 1} 9.56{col 46}{space 3}0.000{col 54}{space 4} .2765944{col 67}{space 3} .420049 {txt}{space 7}_cons {c |}{col 14}{res}{space 2}-.3640786{col 26}{space 2} .2156111{col 37}{space 1} -1.69{col 46}{space 3}0.092{col 54}{space 4}-.7885367{col 67}{space 3} .0603794 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. dfbeta {txt}_dfbeta_1: dfbeta(age) _dfbeta_2: dfbeta(lweight) {com}. graph box _dfbeta_1 _dfbeta_2, name(boxplot1, replace) {res}{txt} {com}. graph export boxplot1.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/boxplot1.pdf written in PDF format) {com}. list bmd age lweight _dfbeta_1 if abs(_dfbeta_1) > 0.2 & ~missing(_dfbeta_1) {txt} {c TLC}{hline 6}{c -}{hline 5}{c -}{hline 10}{c -}{hline 11}{c TRC} {c |} {res} bmd age lweight _dfbeta_1 {txt}{c |} {c LT}{hline 6}{c -}{hline 5}{c -}{hline 10}{c -}{hline 11}{c RT} 140. {c |} {res}.458 88 4.234107 -.2716317 {txt}{c |} 151. {c |} {res}.914 90 4.023564 .3781947 {txt}{c |} 200. {c |} {res} .91 87 4.219508 .2188265 {txt}{c |} {c BLC}{hline 6}{c -}{hline 5}{c -}{hline 10}{c -}{hline 11}{c BRC} {com}. list bmd age lweight _dfbeta_2 if abs(_dfbeta_2) > 0.2 & ~missing(_dfbeta_2) {txt} {c TLC}{hline 7}{c -}{hline 5}{c -}{hline 10}{c -}{hline 10}{c TRC} {c |} {res} bmd age lweight _dfbet~2 {txt}{c |} {c LT}{hline 7}{c -}{hline 5}{c -}{hline 10}{c -}{hline 10}{c RT} 94. {c |} {res} 1.18 78 4.435567 .2476206 {txt}{c |} 108. {c |} {res} .366 82 3.720862 .2242683 {txt}{c |} 231. {c |} {res} .441 73 3.642836 .2110856 {txt}{c |} 262. {c |} {res}1.193 78 4.390738 .2162125 {txt}{c |} {c BLC}{hline 7}{c -}{hline 5}{c -}{hline 10}{c -}{hline 10}{c BRC} {com}. reg bmd age lweight if abs(_dfbeta_1) <= .2 & abs(_dfbeta_2) <= 0.2 {txt}Source {c |} SS df MS Number of obs ={res} 271 {txt}{hline 13}{char +}{hline 30} F( 2, 268) ={res} 60.60 {txt} Model {char |} {res} 1.37868504 2 .689342521 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.0485926 268 .011375346 {txt}R-squared = {res} 0.3114 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.3063 {txt} Total {char |} {res} 4.42727765 270 .016397325 {txt}Root MSE = {res} .10666 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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}age {c |}{col 14}{res}{space 2}-.0055429{col 26}{space 2} .0014588{col 37}{space 1} -3.80{col 46}{space 3}0.000{col 54}{space 4} -.008415{col 67}{space 3}-.0026708 {txt}{space 5}lweight {c |}{col 14}{res}{space 2} .3168664{col 26}{space 2} .0352548{col 37}{space 1} 8.99{col 46}{space 3}0.000{col 54}{space 4} .2474548{col 67}{space 3} .3862781 {txt}{space 7}_cons {c |}{col 14}{res}{space 2}-.1709832{col 26}{space 2} .2094359{col 37}{space 1} -0.82{col 46}{space 3}0.415{col 54}{space 4}-.5833321{col 67}{space 3} .2413656 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. . * checking overlap . recode estrogen 1=0 2=1, gen(ht_current) {txt}(124 differences between estrogen and ht_current) {com}. label values ht_current yesno {txt} {com}. tab estrogen ht_current {txt}current or {c |} RECODE of estrogen past {c |} (current or past estrogen {c |} estrogen use) use {c |} no yes {c |} Total {hline 11}{c +}{hline 22}{c +}{hline 10} never {c |}{res} 154 0 {txt}{c |}{res} 154 {txt} past {c |}{res} 74 0 {txt}{c |}{res} 74 {txt} current {c |}{res} 0 50 {txt}{c |}{res} 50 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} Total {c |}{res} 228 50 {txt}{c |}{res} 278 {txt} {com}. foreach x in age bmi gaitspd has10 {c -(} {txt} 2{com}. table ht_current, c(mean `x' p5 `x' min `x' p95 `x' max `x') {txt} 3{com}. {c )-} {txt}{hline 10}{c TT}{hline 59} RECODE of {c |} estrogen {c |} (current {c |} or past {c |} estrogen {c |} use) {c |} mean(age) p5(age) min(age) p95(age) max(age) {hline 10}{c +}{hline 59} no {c |} {res}78.91666 73 72 89 95 {txt}yes {c |} {res}77.04 73 73 83 87 {txt}{hline 10}{c BT}{hline 59} {hline 10}{c TT}{hline 59} RECODE of {c |} estrogen {c |} (current {c |} or past {c |} estrogen {c |} use) {c |} mean(bmi) p5(bmi) min(bmi) p95(bmi) max(bmi) {hline 10}{c +}{hline 59} no {c |} {res}27.0989 20.153 14.875 35.466 44.894 {txt}yes {c |} {res}27.14962 20.587 20.134 33.566 37.608 {txt}{hline 10}{c BT}{hline 59} {hline 10}{c TT}{hline 69} RECODE of {c |} estrogen {c |} (current {c |} or past {c |} estrogen {c |} use) {c |} mean(gait~d) p5(gaitspd) min(gaitspd) p95(gaitspd) max(gaitspd) {hline 10}{c +}{hline 69} no {c |} {res}.930329 .588 .299 1.25 1.429 {txt}yes {c |} {res}.9680612 .606 .401 1.304 1.5 {txt}{hline 10}{c BT}{hline 69} {hline 10}{c TT}{hline 64} RECODE of {c |} estrogen {c |} (current {c |} or past {c |} estrogen {c |} use) {c |} mean(has10) p5(has10) min(has10) p95(has10) max(has10) {hline 10}{c +}{hline 64} no {c |} {res}.9177778 .5 .3 1.45 1.85 {txt}yes {c |} {res}.986 .65 .45 1.45 1.65 {txt}{hline 10}{c BT}{hline 64} {com}. foreach x in usearms poorhlth calsupp etid nsfx2 {c -(} {txt} 2{com}. tab ht_current `x', row {txt} 3{com}. {c )-} {txt} {c TLC}{hline 16}{c TRC} {c |} Key{col 18}{c |} {c LT}{hline 16}{c RT} {c |}{space 3}{it:frequency}{col 18}{c |} {c |}{space 1}{it:row percentage}{col 18}{c |} {c BLC}{hline 16}{c BRC} RECODE of {c |} estrogen {c |} (current {c |} or past {c |} estrogen {c |} use arms to stand up use) {c |} no yes {c |} Total {hline 11}{c +}{hline 22}{c +}{hline 10} no {c |}{res} 204 24 {txt}{c |}{res} 228 {txt}{c |}{res} 89.47 10.53 {txt}{c |}{res} 100.00 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} yes {c |}{res} 43 5 {txt}{c |}{res} 48 {txt}{c |}{res} 89.58 10.42 {txt}{c |}{res} 100.00 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} Total {c |}{res} 247 29 {txt}{c |}{res} 276 {txt}{c |}{res} 89.49 10.51 {txt}{c |}{res} 100.00 {txt} {c TLC}{hline 16}{c TRC} {c |} Key{col 18}{c |} {c LT}{hline 16}{c RT} {c |}{space 3}{it:frequency}{col 18}{c |} {c |}{space 1}{it:row percentage}{col 18}{c |} {c BLC}{hline 16}{c BRC} RECODE of {c |} estrogen {c |} (current {c |} or past {c |} poor health by estrogen {c |} self-report use) {c |} no yes {c |} Total {hline 11}{c +}{hline 22}{c +}{hline 10} no {c |}{res} 179 49 {txt}{c |}{res} 228 {txt}{c |}{res} 78.51 21.49 {txt}{c |}{res} 100.00 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} yes {c |}{res} 38 12 {txt}{c |}{res} 50 {txt}{c |}{res} 76.00 24.00 {txt}{c |}{res} 100.00 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} Total {c |}{res} 217 61 {txt}{c |}{res} 278 {txt}{c |}{res} 78.06 21.94 {txt}{c |}{res} 100.00 {txt} {c TLC}{hline 16}{c TRC} {c |} Key{col 18}{c |} {c LT}{hline 16}{c RT} {c |}{space 3}{it:frequency}{col 18}{c |} {c |}{space 1}{it:row percentage}{col 18}{c |} {c BLC}{hline 16}{c BRC} RECODE of {c |} estrogen {c |} (current {c |} or past {c |} last 30 days: taken estrogen {c |} calcium supplements use) {c |} no yes {c |} Total {hline 11}{c +}{hline 22}{c +}{hline 10} no {c |}{res} 156 72 {txt}{c |}{res} 228 {txt}{c |}{res} 68.42 31.58 {txt}{c |}{res} 100.00 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} yes {c |}{res} 22 28 {txt}{c |}{res} 50 {txt}{c |}{res} 44.00 56.00 {txt}{c |}{res} 100.00 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} Total {c |}{res} 178 100 {txt}{c |}{res} 278 {txt}{c |}{res} 64.03 35.97 {txt}{c |}{res} 100.00 {txt} {c TLC}{hline 16}{c TRC} {c |} Key{col 18}{c |} {c LT}{hline 16}{c RT} {c |}{space 3}{it:frequency}{col 18}{c |} {c |}{space 1}{it:row percentage}{col 18}{c |} {c BLC}{hline 16}{c BRC} RECODE of {c |} estrogen {c |} (current {c |} or past {c |} last 2 years: used estrogen {c |} Etidronate use) {c |} no yes {c |} Total {hline 11}{c +}{hline 22}{c +}{hline 10} no {c |}{res} 225 3 {txt}{c |}{res} 228 {txt}{c |}{res} 98.68 1.32 {txt}{c |}{res} 100.00 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} yes {c |}{res} 49 1 {txt}{c |}{res} 50 {txt}{c |}{res} 98.00 2.00 {txt}{c |}{res} 100.00 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} Total {c |}{res} 274 4 {txt}{c |}{res} 278 {txt}{c |}{res} 98.56 1.44 {txt}{c |}{res} 100.00 {txt} {c TLC}{hline 16}{c TRC} {c |} Key{col 18}{c |} {c LT}{hline 16}{c RT} {c |}{space 3}{it:frequency}{col 18}{c |} {c |}{space 1}{it:row percentage}{col 18}{c |} {c BLC}{hline 16}{c BRC} RECODE of {c |} estrogen {c |} (current {c |} or past {c |} non-spine fracture in estrogen {c |} last 2 years use) {c |} no yes {c |} Total {hline 11}{c +}{hline 22}{c +}{hline 10} no {c |}{res} 209 19 {txt}{c |}{res} 228 {txt}{c |}{res} 91.67 8.33 {txt}{c |}{res} 100.00 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} yes {c |}{res} 46 4 {txt}{c |}{res} 50 {txt}{c |}{res} 92.00 8.00 {txt}{c |}{res} 100.00 {txt}{hline 11}{c +}{hline 22}{c +}{hline 10} Total {c |}{res} 255 23 {txt}{c |}{res} 278 {txt}{c |}{res} 91.73 8.27 {txt}{c |}{res} 100.00 {txt} {com}. mkspline agesp = age, cubic {txt} {com}. mkspline bmisp = bmi, cubic {txt} {com}. mkspline gaitspdsp = gaitspd, cubic {txt} {com}. mkspline has10sp = has10, cubic {txt} {com}. sw, pr(.2): logistic ht_current (agesp*) (bmisp*) (has10*) nsfx2 calsupp etid (gaitspdsp*) {txt}note: has10sp1 dropped because of collinearity {p2colset 0 23 32 2}{...} {p2col :}begin with full model{p_end} {p2col :p = {res:0.9631} >= 0.2000}removing {res:etid}{p_end} {p2col :p = {res:0.6373} >= 0.2000}removing {res:nsfx2}{p_end} {p2col :p = {res:0.5327} >= 0.2000}removing {res:gaitspdsp1 gaitspdsp2 gaitspdsp3 gaitspdsp4}{p_end} {p2col :p = {res:0.3872} >= 0.2000}removing {res:bmisp1 bmisp2 bmisp3 bmisp4}{p_end} {p2col :p = {res:0.4245} >= 0.2000}removing {res:has10 has10sp2 has10sp3 has10sp4}{p_end} {p2colreset}{...} Logistic regression{col 51}Number of obs{col 67}= {res} 274 {txt}{col 51}LR chi2({res}5{txt}){col 67}= {res} 17.76 {txt}{col 51}Prob > chi2{col 67}= {res} 0.0033 {txt}Log likelihood = {res}-119.79665{txt}{col 51}Pseudo R2{col 67}= {res} 0.0690 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} ht_current{col 14}{c |} Odds Ratio{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 6}agesp1 {c |}{col 14}{res}{space 2} .6577646{col 26}{space 2} .2254138{col 37}{space 1} -1.22{col 46}{space 3}0.222{col 54}{space 4} .3360211{col 67}{space 3} 1.287581 {txt}{space 6}agesp2 {c |}{col 14}{res}{space 2} 491.5358{col 26}{space 2} 2705.423{col 37}{space 1} 1.13{col 46}{space 3}0.260{col 54}{space 4} .0101513{col 67}{space 3} 2.38e+07 {txt}{space 6}agesp3 {c |}{col 14}{res}{space 2} 1.01e-06{col 26}{space 2} .0000127{col 37}{space 1} -1.10{col 46}{space 3}0.273{col 54}{space 4} 1.93e-17{col 67}{space 3} 52520.76 {txt}{space 6}agesp4 {c |}{col 14}{res}{space 2} 12798.96{col 26}{space 2} 128111.7{col 37}{space 1} 0.94{col 46}{space 3}0.345{col 54}{space 4} .0000386{col 67}{space 3} 4.24e+12 {txt}{space 5}calsupp {c |}{col 14}{res}{space 2} 2.493148{col 26}{space 2} .8247382{col 37}{space 1} 2.76{col 46}{space 3}0.006{col 54}{space 4} 1.303674{col 67}{space 3} 4.767901 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} 5.08e+12{col 26}{space 2} 1.28e+14{col 37}{space 1} 1.16{col 46}{space 3}0.247{col 54}{space 4} 1.55e-09{col 67}{space 3} 1.67e+34 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. logistic ht_current agesp* calsupp {res} {txt}Logistic regression{col 51}Number of obs{col 67}= {res} 278 {txt}{col 51}LR chi2({res}5{txt}){col 67}= {res} 19.18 {txt}{col 51}Prob > chi2{col 67}= {res} 0.0018 {txt}Log likelihood = {res}-121.39847{txt}{col 51}Pseudo R2{col 67}= {res} 0.0732 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} ht_current{col 14}{c |} Odds Ratio{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 6}agesp1 {c |}{col 14}{res}{space 2} .6542074{col 26}{space 2} .2239392{col 37}{space 1} -1.24{col 46}{space 3}0.215{col 54}{space 4} .3344598{col 67}{space 3} 1.279638 {txt}{space 6}agesp2 {c |}{col 14}{res}{space 2} 744.7702{col 26}{space 2} 4079.485{col 37}{space 1} 1.21{col 46}{space 3}0.227{col 54}{space 4} .0162016{col 67}{space 3} 3.42e+07 {txt}{space 6}agesp3 {c |}{col 14}{res}{space 2} 3.17e-07{col 26}{space 2} 3.97e-06{col 37}{space 1} -1.20{col 46}{space 3}0.231{col 54}{space 4} 7.18e-18{col 67}{space 3} 14012.11 {txt}{space 6}agesp4 {c |}{col 14}{res}{space 2} 39901.15{col 26}{space 2} 395380.3{col 37}{space 1} 1.07{col 46}{space 3}0.285{col 54}{space 4} .0001467{col 67}{space 3} 1.09e+13 {txt}{space 5}calsupp {c |}{col 14}{res}{space 2} 2.638898{col 26}{space 2} .8679393{col 37}{space 1} 2.95{col 46}{space 3}0.003{col 54}{space 4} 1.385034{col 67}{space 3} 5.027877 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} 7.19e+12{col 26}{space 2} 1.82e+14{col 37}{space 1} 1.17{col 46}{space 3}0.241{col 54}{space 4} 2.33e-09{col 67}{space 3} 2.22e+34 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. testparm agesp* {p 0 7}{space 1}{text:( 1)}{space 1} {res}[ht_current]agesp1 = 0{p_end} {p 0 7}{space 1}{text:( 2)}{space 1} [ht_current]agesp2 = 0{p_end} {p 0 7}{space 1}{text:( 3)}{space 1} [ht_current]agesp3 = 0{p_end} {p 0 7}{space 1}{text:( 4)}{space 1} [ht_current]agesp4 = 0{p_end} {txt}{col 12}chi2( 4) ={res} 6.39 {txt}{col 10}Prob > chi2 = {res} 0.1719 {txt} {com}. predict logit_pscore, xb {txt} {com}. tab ht_current, sum(logit_pscore) {txt}RECODE of {c |} estrogen {c |} (current or {c |} past {c |} Summary of Linear prediction (log estrogen {c |} odds) use) {c |} Mean Std. Dev. Freq. {hline 12}{c +}{hline 36} no {c |} {res}-1.8217386 .90527908 228 {txt} yes {c |} {res} -1.28434 .59299373 50 {txt}{hline 12}{c +}{hline 36} Total {c |} {res}-1.7250842 .88122527 278 {txt} {com}. twoway (kdensity logit_pscore if estrogen==1, area(1) lpattern(solid)) /// > (kdensity logit_pscore if estrogen==0, area(1) lpattern(longdash)), /// > ytitle("Density") xtitle("Logit Propensity Score") /// > legend(order(1 "Current estrogen users" 2 "Past and never users")) /// > name(pscores, replace) {res}{txt} {com}. graph export pscores.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/pscores.pdf written in PDF format) {com}. . * optional section on splines . capture drop bmicat {txt} {com}. capture drop fitted* {txt} {com}. recode bmi min/18.5=1 18.5001/25=2 25.0001/30=3 30.00001/35=4 35.00001/max=5, gen(bmicat) {txt}(278 differences between bmi and bmicat) {com}. xi: reg bmd i.bmicat age i.estrogen {txt}i.bmicat{col 19}_Ibmicat_1-5{col 39}(naturally coded; _Ibmicat_1 omitted) i.estrogen{col 19}_Iestrogen_0-2{col 39}(naturally coded; _Iestrogen_0 omitted) Source {c |} SS df MS Number of obs ={res} 278 {txt}{hline 13}{char +}{hline 30} F( 7, 270) ={res} 16.67 {txt} Model {char |} {res} 1.57067458 7 .224382083 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.63366925 270 .013458034 {txt}R-squared = {res} 0.3018 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.2837 {txt} Total {char |} {res} 5.20434383 277 .018788245 {txt}Root MSE = {res} .11601 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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 2}_Ibmicat_2 {c |}{col 14}{res}{space 2} .1473241{col 26}{space 2} .0494168{col 37}{space 1} 2.98{col 46}{space 3}0.003{col 54}{space 4} .0500329{col 67}{space 3} .2446154 {txt}{space 2}_Ibmicat_3 {c |}{col 14}{res}{space 2} .2002839{col 26}{space 2} .049321{col 37}{space 1} 4.06{col 46}{space 3}0.000{col 54}{space 4} .1031813{col 67}{space 3} .2973864 {txt}{space 2}_Ibmicat_4 {c |}{col 14}{res}{space 2} .2845589{col 26}{space 2} .0510954{col 37}{space 1} 5.57{col 46}{space 3}0.000{col 54}{space 4} .1839629{col 67}{space 3} .3851549 {txt}{space 2}_Ibmicat_5 {c |}{col 14}{res}{space 2} .2922039{col 26}{space 2} .0563304{col 37}{space 1} 5.19{col 46}{space 3}0.000{col 54}{space 4} .1813013{col 67}{space 3} .4031065 {txt}{space 9}age {c |}{col 14}{res}{space 2}-.0044677{col 26}{space 2} .0015618{col 37}{space 1} -2.86{col 46}{space 3}0.005{col 54}{space 4}-.0075425{col 67}{space 3}-.0013929 {txt}_Iestrogen_1 {c |}{col 14}{res}{space 2} .0386094{col 26}{space 2} .0167944{col 37}{space 1} 2.30{col 46}{space 3}0.022{col 54}{space 4} .0055448{col 67}{space 3} .071674 {txt}_Iestrogen_2 {c |}{col 14}{res}{space 2} .0692431{col 26}{space 2} .0193894{col 37}{space 1} 3.57{col 46}{space 3}0.000{col 54}{space 4} .0310694{col 67}{space 3} .1074168 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .854929{col 26}{space 2} .1399065{col 37}{space 1} 6.11{col 46}{space 3}0.000{col 54}{space 4} .5794826{col 67}{space 3} 1.130375 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. qui adjust age _Iestrogen_*, gen(fitted1) xb {txt} {com}. * rerun using Version 13 notation to test for trend, departure from linearity . reg bmd i.bmicat age i.estrogen {txt}Source {c |} SS df MS Number of obs ={res} 278 {txt}{hline 13}{char +}{hline 30} F( 7, 270) ={res} 16.67 {txt} Model {char |} {res} 1.57067458 7 .224382083 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.63366925 270 .013458034 {txt}R-squared = {res} 0.3018 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.2837 {txt} Total {char |} {res} 5.20434383 277 .018788245 {txt}Root MSE = {res} .11601 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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 6}bmicat {c |} {space 10}2 {c |}{col 14}{res}{space 2} .1473241{col 26}{space 2} .0494168{col 37}{space 1} 2.98{col 46}{space 3}0.003{col 54}{space 4} .0500329{col 67}{space 3} .2446154 {txt}{space 10}3 {c |}{col 14}{res}{space 2} .2002839{col 26}{space 2} .049321{col 37}{space 1} 4.06{col 46}{space 3}0.000{col 54}{space 4} .1031813{col 67}{space 3} .2973864 {txt}{space 10}4 {c |}{col 14}{res}{space 2} .2845589{col 26}{space 2} .0510954{col 37}{space 1} 5.57{col 46}{space 3}0.000{col 54}{space 4} .1839629{col 67}{space 3} .3851549 {txt}{space 10}5 {c |}{col 14}{res}{space 2} .2922039{col 26}{space 2} .0563304{col 37}{space 1} 5.19{col 46}{space 3}0.000{col 54}{space 4} .1813013{col 67}{space 3} .4031065 {txt}{space 12} {c |} {space 9}age {c |}{col 14}{res}{space 2}-.0044677{col 26}{space 2} .0015618{col 37}{space 1} -2.86{col 46}{space 3}0.005{col 54}{space 4}-.0075425{col 67}{space 3}-.0013929 {txt}{space 12} {c |} {space 4}estrogen {c |} {space 7}past {c |}{col 14}{res}{space 2} .0386094{col 26}{space 2} .0167944{col 37}{space 1} 2.30{col 46}{space 3}0.022{col 54}{space 4} .0055448{col 67}{space 3} .071674 {txt}{space 4}current {c |}{col 14}{res}{space 2} .0692431{col 26}{space 2} .0193894{col 37}{space 1} 3.57{col 46}{space 3}0.000{col 54}{space 4} .0310694{col 67}{space 3} .1074168 {txt}{space 12} {c |} {space 7}_cons {c |}{col 14}{res}{space 2} .854929{col 26}{space 2} .1399065{col 37}{space 1} 6.11{col 46}{space 3}0.000{col 54}{space 4} .5794826{col 67}{space 3} 1.130375 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. * test for linear trend across categories . contrast q(1).bmicat {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 6}bmicat {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 39.46{col 38}{space 2} 0.0000 {col 14}{text}{c |} {col 1}{text} Denominator{col 14}{c |}{result}{space 2} 270 {col 1}{text}{hline 13}{c BT}{hline 11}{hline 12}{hline 11} {res}{txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 14}{hline 12} {col 14}{c |} Contrast{col 26} Std. Err.{col 38} [95% Con{col 51}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 14}{hline 12} {space 6}bmicat {c |} {space 3}(linear) {c |}{col 14}{res}{space 2} .1020557{col 26}{space 2} .0162455{col 37}{space 5} .0700717{col 51}{space 3} .1340396 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 14}{hline 12} {com}. * test for departure from linearity . contrast q(2/4).bmicat {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 6}bmicat {c |} (quadratic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 4.65{col 38}{space 2} 0.0320 {txt} (cubic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 0.06{col 38}{space 2} 0.7993 {txt} (quartic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 3.85{col 38}{space 2} 0.0509 {col 1}{text} Joint {col 14}{c |}{result}{space 2} 3{col 26}{space 3} 1.97{col 38}{space 2} 0.1186 {col 14}{text}{c |} {col 1}{text} Denominator{col 14}{c |}{result}{space 2} 270 {col 1}{text}{hline 13}{c BT}{hline 11}{hline 12}{hline 11} {res}{txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 14}{hline 12} {col 14}{c |} Contrast{col 26} Std. Err.{col 38} [95% Con{col 51}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 14}{hline 12} {space 6}bmicat {c |} (quadratic) {c |}{col 14}{res}{space 2}-.0296468{col 26}{space 2} .0137502{col 37}{space 5} -.056718{col 51}{space 3}-.0025756 {txt} (cubic) {c |}{col 14}{res}{space 2} .002508{col 26}{space 2} .0098528{col 37}{space 5}-.0168901{col 51}{space 3} .0219061 {txt} (quartic) {c |}{col 14}{res}{space 2}-.0124878{col 26}{space 2} .0063676{col 37}{space 5}-.0250242{col 51}{space 3} .0000486 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 14}{hline 12} {com}. . * linear splines . capture drop bmi1 bmi2 bmi3 bmi4 bmi5 {txt} {com}. mkspline bmi1 18.5 bmi2 25 bmi3 30 bmi4 35 bmi5 = bmi {txt} {com}. xi: reg bmd bmi1-bmi5 age i.estrogen {txt}i.estrogen{col 19}_Iestrogen_0-2{col 39}(naturally coded; _Iestrogen_0 omitted) Source {c |} SS df MS Number of obs ={res} 278 {txt}{hline 13}{char +}{hline 30} F( 8, 269) ={res} 16.65 {txt} Model {char |} {res} 1.723868 8 .2154835 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.48047583 269 .012938572 {txt}R-squared = {res} 0.3312 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.3113 {txt} Total {char |} {res} 5.20434383 277 .018788245 {txt}Root MSE = {res} .11375 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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 8}bmi1 {c |}{col 14}{res}{space 2} .0479726{col 26}{space 2} .0288431{col 37}{space 1} 1.66{col 46}{space 3}0.097{col 54}{space 4}-.0088143{col 67}{space 3} .1047595 {txt}{space 8}bmi2 {c |}{col 14}{res}{space 2} .0142805{col 26}{space 2} .0058679{col 37}{space 1} 2.43{col 46}{space 3}0.016{col 54}{space 4} .0027277{col 67}{space 3} .0258333 {txt}{space 8}bmi3 {c |}{col 14}{res}{space 2} .018217{col 26}{space 2} .0051934{col 37}{space 1} 3.51{col 46}{space 3}0.001{col 54}{space 4} .0079922{col 67}{space 3} .0284418 {txt}{space 8}bmi4 {c |}{col 14}{res}{space 2} .0014476{col 26}{space 2} .0067401{col 37}{space 1} 0.21{col 46}{space 3}0.830{col 54}{space 4}-.0118225{col 67}{space 3} .0147178 {txt}{space 8}bmi5 {c |}{col 14}{res}{space 2} .0115979{col 26}{space 2} .0073531{col 37}{space 1} 1.58{col 46}{space 3}0.116{col 54}{space 4}-.0028792{col 67}{space 3} .0260749 {txt}{space 9}age {c |}{col 14}{res}{space 2}-.0039816{col 26}{space 2} .0015351{col 37}{space 1} -2.59{col 46}{space 3}0.010{col 54}{space 4} -.007004{col 67}{space 3}-.0009592 {txt}_Iestrogen_1 {c |}{col 14}{res}{space 2} .0427419{col 26}{space 2} .0165707{col 37}{space 1} 2.58{col 46}{space 3}0.010{col 54}{space 4} .0101172{col 67}{space 3} .0753666 {txt}_Iestrogen_2 {c |}{col 14}{res}{space 2} .0735367{col 26}{space 2} .0190421{col 37}{space 1} 3.86{col 46}{space 3}0.000{col 54}{space 4} .0360462{col 67}{space 3} .1110273 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .0061371{col 26}{space 2} .5363318{col 37}{space 1} 0.01{col 46}{space 3}0.991{col 54}{space 4}-1.049805{col 67}{space 3} 1.062079 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. qui adjust age _Iestrogen_*, gen(fitted2) xb {txt} {com}. * test for departure from linear trend . testparm bmi*, equal {p 0 7}{space 1}{text:( 1)}{space 1}{space 1}{res}- bmi1 + bmi2 = 0{p_end} {p 0 7}{space 1}{text:( 2)}{space 1}{space 1}{res}- bmi1 + bmi3 = 0{p_end} {p 0 7}{space 1}{text:( 3)}{space 1}{space 1}{res}- bmi1 + bmi4 = 0{p_end} {p 0 7}{space 1}{text:( 4)}{space 1}{space 1}{res}- bmi1 + bmi5 = 0{p_end} {txt} F( 4, 269) ={res} 1.69 {txt}{col 13}Prob > F ={res} 0.1524 {txt} {com}. . * cubic splines . capture drop bmisp* {txt} {com}. mkspline bmisp = bmi, cubic {txt} {com}. xi: reg bmd bmisp* age i.estrogen {txt}i.estrogen{col 19}_Iestrogen_0-2{col 39}(naturally coded; _Iestrogen_0 omitted) Source {c |} SS df MS Number of obs ={res} 278 {txt}{hline 13}{char +}{hline 30} F( 7, 270) ={res} 19.68 {txt} Model {char |} {res} 1.75848253 7 .25121179 {txt}Prob > F = {res} 0.0000 {txt}Residual {char |} {res} 3.44586131 270 .012762449 {txt}R-squared = {res} 0.3379 {txt}{hline 13}{char +}{hline 30} Adj R-squared = {res} 0.3207 {txt} Total {char |} {res} 5.20434383 277 .018788245 {txt}Root MSE = {res} .11297 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} bmd{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 6}bmisp1 {c |}{col 14}{res}{space 2} .0314653{col 26}{space 2} .0076344{col 37}{space 1} 4.12{col 46}{space 3}0.000{col 54}{space 4} .0164347{col 67}{space 3} .0464959 {txt}{space 6}bmisp2 {c |}{col 14}{res}{space 2}-.1377472{col 26}{space 2} .058356{col 37}{space 1} -2.36{col 46}{space 3}0.019{col 54}{space 4}-.2526379{col 67}{space 3}-.0228566 {txt}{space 6}bmisp3 {c |}{col 14}{res}{space 2} .6172104{col 26}{space 2} .2652112{col 37}{space 1} 2.33{col 46}{space 3}0.021{col 54}{space 4} .0950654{col 67}{space 3} 1.139355 {txt}{space 6}bmisp4 {c |}{col 14}{res}{space 2}-.7514937{col 26}{space 2} .328523{col 37}{space 1} -2.29{col 46}{space 3}0.023{col 54}{space 4}-1.398286{col 67}{space 3}-.1047012 {txt}{space 9}age {c |}{col 14}{res}{space 2}-.0038331{col 26}{space 2} .0015263{col 37}{space 1} -2.51{col 46}{space 3}0.013{col 54}{space 4} -.006838{col 67}{space 3}-.0008281 {txt}_Iestrogen_1 {c |}{col 14}{res}{space 2} .0361593{col 26}{space 2} .0162605{col 37}{space 1} 2.22{col 46}{space 3}0.027{col 54}{space 4} .0041458{col 67}{space 3} .0681729 {txt}_Iestrogen_2 {c |}{col 14}{res}{space 2} .0732025{col 26}{space 2} .0189018{col 37}{space 1} 3.87{col 46}{space 3}0.000{col 54}{space 4} .0359889{col 67}{space 3} .1104161 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .2581214{col 26}{space 2} .2166109{col 37}{space 1} 1.19{col 46}{space 3}0.234{col 54}{space 4}-.1683398{col 67}{space 3} .6845826 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. qui adjust age _Iestrogen_*, gen(fitted3) xb {txt} {com}. * test for overall BMI effect . testparm bmisp* {p 0 7}{space 1}{text:( 1)}{space 1} {res}bmisp1 = 0{p_end} {p 0 7}{space 1}{text:( 2)}{space 1} bmisp2 = 0{p_end} {p 0 7}{space 1}{text:( 3)}{space 1} bmisp3 = 0{p_end} {p 0 7}{space 1}{text:( 4)}{space 1} bmisp4 = 0{p_end} {txt} F( 4, 270) ={res} 22.07 {txt}{col 13}Prob > F ={res} 0.0000 {txt} {com}. * test for departure from linearity . testparm bmisp2 bmisp3 bmisp4 {p 0 7}{space 1}{text:( 1)}{space 1} {res}bmisp2 = 0{p_end} {p 0 7}{space 1}{text:( 2)}{space 1} bmisp3 = 0{p_end} {p 0 7}{space 1}{text:( 3)}{space 1} bmisp4 = 0{p_end} {txt} F( 3, 270) ={res} 3.19 {txt}{col 13}Prob > F ={res} 0.0242 {txt} {com}. . twoway /// > (scatter bmd bmi, msize(vtiny)) /// > (line fitted1 bmi, sort c(J) lp(longdash) lcol(red) lw(medthick)) /// > (line fitted2 bmi, sort lp(shortdash) lcol(green) lw(medthick)) /// > (line fitted3 bmi, sort lp(shortdash) lcol(black) lw(medthick)) /// > (lowess bmd bmi, lp(solid) lcol(blue) lw(medthick)), /// > plotregion(style(none)) scheme(s1color) ytitle("BMD (gm/cm^2)") /// > legend(order(2 "Categorical" 3 "Linear Spline" 4 "Cubic Spline" 5 "Lowess") /// > rows(2)) caption(Adjusted for age and estrogen use) name(splinefit, replace) {res}{txt} {com}. graph export splinefit.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/splinefit.pdf written in PDF format) {com}. . log close {txt}name: {res} {txt}log: {res}/Users/steve/Documents/teaching/c2015/biostat208/labs/lab6/lab6.smcl {txt}log type: {res}smcl {txt}closed on: {res}10 Feb 2015, 08:37:30 {txt}{.-} {smcl} {txt}{sf}{ul off}