{smcl} {com}{sf}{ul off}{txt}{.-} name: {res} {txt}log: {res}/Users/steve/Documents/teaching/c2015/biostat208/labs/lab8/lab8.smcl {txt}log type: {res}smcl {txt}opened on: {res}26 Feb 2015, 10:01:55 {txt} {com}. * summaries . des {txt}Contains data from {res}lab8.dta {txt} obs:{res} 3,154 {txt} vars:{res} 14 2 Feb 2000 13:27 {txt} size:{res} 176,624 {txt}{hline} storage display value variable name type format label variable label {hline} {p 0 48}{res}{bind:id }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind: }{bind: }{res}{res}id{p_end} {p 0 48}{bind:age }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind: }{bind: }{res}{res}age{p_end} {p 0 48}{bind:height }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind: }{bind: }{res}{res}height (inches){p_end} {p 0 48}{bind:weight }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind: }{bind: }{res}{res}weight (lbs){p_end} {p 0 48}{bind:sbp }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind: }{bind: }{res}{res}systolic BP{p_end} {p 0 48}{bind:dbp }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind: }{bind: }{res}{res}diastolic BP{p_end} {p 0 48}{bind:chol }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind: }{bind: }{res}{res}total cholesterol{p_end} {p 0 48}{bind:behpat }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind:bpat4 }{bind: }{res}{res}behavioral pattern (4 level){p_end} {p 0 48}{bind:ncigs }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind: }{bind: }{res}{res}cigarettes smoked per day{p_end} {p 0 48}{bind:dibpat }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind:bpat2 }{bind: }{res}{res}behavioral pattern (A vs. B){p_end} {p 0 48}{bind:chd69 }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind:ind }{bind: }{res}{res}CHD event{p_end} {p 0 48}{bind:typchd69 }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind:chdtype }{bind: }{res}{res}type of event{p_end} {p 0 48}{bind:time169 }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind: }{bind: }{res}{res}follow-up time (days){p_end} {p 0 48}{bind:arcus }{txt}{bind: float }{bind:{txt}%9.0g }{space 1}{bind:pamiss }{bind: }{res}{res}arcus senilis{p_end} {txt}{hline} Sorted by: {com}. sum {txt} Variable {c |} Obs Mean Std. Dev. Min Max {hline 13}{c +}{hline 56} {space 10}id {c |}{res} 3154 10477.94 5877.376 2001 22101 {txt}{space 9}age {c |}{res} 3154 46.27869 5.524045 39 59 {txt}{space 6}height {c |}{res} 3154 69.77774 2.528693 60 78 {txt}{space 6}weight {c |}{res} 3154 169.9537 21.09576 78 320 {txt}{space 9}sbp {c |}{res} 3154 128.6328 15.11773 98 230 {txt}{hline 13}{c +}{hline 56} {space 9}dbp {c |}{res} 3154 82.01554 9.72688 58 150 {txt}{space 8}chol {c |}{res} 3142 226.3724 43.42043 103 645 {txt}{space 6}behpat {c |}{res} 3154 2.523145 .7989865 1 4 {txt}{space 7}ncigs {c |}{res} 3154 11.60051 14.51758 0 99 {txt}{space 6}dibpat {c |}{res} 3154 .5038047 .5000648 0 1 {txt}{hline 13}{c +}{hline 56} {space 7}chd69 {c |}{res} 3154 .0814838 .2736201 0 1 {txt}{space 4}typchd69 {c |}{res} 3154 .1363348 .5097763 0 3 {txt}{space 5}time169 {c |}{res} 3154 2683.859 666.5241 18 3430 {txt}{space 7}arcus {c |}{res} 3152 .2985406 .4576905 0 1 {txt} {com}. . * assoc. between CHD & arcus . . * using cs . cs chd69 arcus, or {col 18}{txt}{c |} arcus senilis{col 43}{c |} {col 18}{c |} Exposed Unexposed {c |} Total {hline 17}{c +}{hline 24}{c +}{hline 12} Cases {c |} {res} 102 153{txt} {c |} {res} 255 {txt}Noncases {c |} {res} 839 2058{txt} {c |} {res} 2897 {txt}{hline 17}{c +}{hline 24}{c +}{hline 12} {col 12}Total {c |} {res} 941 2211{txt} {c |} {res} 3152 {txt}{col 18}{c |}{col 43}{c |} Risk {c |} {res} .1083953 .0691995{txt} {c |} {res} .080901 {txt}{col 18}{c |}{col 43}{c |} {col 18}{c |} Point estimate {c |} [95% Conf. Interval] {col 18}{c LT}{hline 24}{c +}{hline 24} Risk difference {c |} {res}{col 27} .0391959{txt}{col 43}{c |} {res} .0166915 .0617003{txt} Risk ratio {c |} {res}{col 27} 1.566419{txt}{col 43}{c |} {res} 1.233865 1.988603{txt} Attr. frac. ex. {c |} {res}{col 27} .3616011{txt}{col 43}{c |} {res} .1895387 .4971343{txt} Attr. frac. pop {c |} {res}{col 27} .1446404{txt}{col 43}{c |} Odds ratio {c |} {res}{col 27} 1.63528{txt}{col 43}{c |} {res} 1.257732 2.126197{txt} (Cornfield) {col 18}{c BLC}{hline 24}{c BT}{hline 24} {col 22} chi2(1) ={res} 13.64{txt} Pr>chi2 ={res} 0.0002 {txt} {com}. . * using logistic . logistic chd69 arcus {res} {txt}Logistic regression{col 51}Number of obs{col 67}= {res} 3152 {txt}{col 51}LR chi2({res}1{txt}){col 67}= {res} 12.98 {txt}{col 51}Prob > chi2{col 67}= {res} 0.0003 {txt}Log likelihood = {res}-879.10783{txt}{col 51}Pseudo R2{col 67}= {res} 0.0073 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} chd69{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 7}arcus {c |}{col 14}{res}{space 2} 1.635281{col 26}{space 2} .2195036{col 37}{space 1} 3.66{col 46}{space 3}0.000{col 54}{space 4} 1.257001{col 67}{space 3} 2.127399 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .074344{col 26}{space 2} .0062298{col 37}{space 1} -31.02{col 46}{space 3}0.000{col 54}{space 4} .0630839{col 67}{space 3} .0876141 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. . * descriptive summaries of age by outcome status . graph box age, over(chd69) name(age_box) {res}{txt} {com}. twoway (kdensity age if chd69==0, bw(3) area(1) lpattern(solid)) (kdensity age if chd69==1, bw(3) area(1) lpattern(longdash)), ytitle("Density") xtitle("age") legend(order(1 "no CHD" 2 "CHD")) name(age_den) {res}{txt} {com}. . * categorical version of age . recode age 36/40=0 41/45=1 46/50=2 51/55=3 56/60=4, gen(agec) {txt}(3154 differences between age and agec) {com}. label define agelab 0 "36-40" 1 "41-45" 2 "46-50" 3 "51-55" 4 "56-60" {txt} {com}. label val agec agelab {txt} {com}. . * CHD by categorical age - frequency tables . tabulate chd69 agec, col {txt} {c TLC}{hline 19}{c TRC} {c |} Key{col 21}{c |} {c LT}{hline 19}{c RT} {c |}{space 5}{it:frequency}{col 21}{c |} {c |}{space 1}{it:column percentage}{col 21}{c |} {c BLC}{hline 19}{c BRC} {c |} RECODE of age (age) CHD event {c |} 36-40 41-45 46-50 51-55 56-60 {c |} Total {hline 11}{c +}{hline 55}{c +}{hline 10} no {c |}{res} 512 1,036 680 463 206 {txt}{c |}{res} 2,897 {txt}{c |}{res} 94.29 94.96 90.67 87.69 85.12 {txt}{c |}{res} 91.85 {txt}{hline 11}{c +}{hline 55}{c +}{hline 10} yes {c |}{res} 31 55 70 65 36 {txt}{c |}{res} 257 {txt}{c |}{res} 5.71 5.04 9.33 12.31 14.88 {txt}{c |}{res} 8.15 {txt}{hline 11}{c +}{hline 55}{c +}{hline 10} Total {c |}{res} 543 1,091 750 528 242 {txt}{c |}{res} 3,154 {txt}{c |}{res} 100.00 100.00 100.00 100.00 100.00 {txt}{c |}{res} 100.00 {txt} {com}. tabodds chd69 agec, or {txt}{hline 13}{c TT}{hline 61} agec {c |} Odds Ratio chi2 P>chi2 [95% Conf. Interval] {hline 13}{c +}{hline 61} {col 8}36-40 {c |} {res}{col 6} 1.000000{col 31} .{col 45} .{col 55} .{col 66} . {txt}{col 8}41-45 {c |} {res}{col 6} 0.876822{col 31} 0.32{col 45}0.5692{col 55} 0.557454{col 66} 1.379156 {txt}{col 8}46-50 {c |} {res}{col 6} 1.700190{col 31} 5.74{col 45}0.0166{col 55} 1.095789{col 66} 2.637958 {txt}{col 8}51-55 {c |} {res}{col 6} 2.318679{col 31} 14.28{col 45}0.0002{col 55} 1.479779{col 66} 3.633160 {txt}{col 8}56-60 {c |} {res}{col 6} 2.886314{col 31} 18.00{col 45}0.0000{col 55} 1.728069{col 66} 4.820876 {txt}{hline 13}{c BT}{hline 61} Test of homogeneity (equal odds): chi2({res}4{txt}) = {res} 46.64 {txt}Pr>chi2 = {res} 0.0000 {txt}Score test for trend of odds: chi2({res}1{txt}) = {res} 40.76 {txt}Pr>chi2 = {res} 0.0000 {txt} {com}. . * CHD by categorical age - logistic model . . logistic chd69 i.agec {res} {txt}Logistic regression{col 51}Number of obs{col 67}= {res} 3154 {txt}{col 51}LR chi2({res}4{txt}){col 67}= {res} 44.95 {txt}{col 51}Prob > chi2{col 67}= {res} 0.0000 {txt}Log likelihood = {res}-868.14866{txt}{col 51}Pseudo R2{col 67}= {res} 0.0252 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} chd69{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 8}agec {c |} {space 6}41-45 {c |}{col 14}{res}{space 2} .8768215{col 26}{space 2} .2025406{col 37}{space 1} -0.57{col 46}{space 3}0.569{col 54}{space 4} .5575563{col 67}{space 3} 1.378903 {txt}{space 6}46-50 {c |}{col 14}{res}{space 2} 1.70019{col 26}{space 2} .3800504{col 37}{space 1} 2.37{col 46}{space 3}0.018{col 54}{space 4} 1.097046{col 67}{space 3} 2.634935 {txt}{space 6}51-55 {c |}{col 14}{res}{space 2} 2.318679{col 26}{space 2} .5274963{col 37}{space 1} 3.70{col 46}{space 3}0.000{col 54}{space 4} 1.484545{col 67}{space 3} 3.621494 {txt}{space 6}56-60 {c |}{col 14}{res}{space 2} 2.886314{col 26}{space 2} .7462298{col 37}{space 1} 4.10{col 46}{space 3}0.000{col 54}{space 4} 1.738895{col 67}{space 3} 4.790864 {txt}{space 12} {c |} {space 7}_cons {c |}{col 14}{res}{space 2} .0605469{col 26}{space 2} .0111989{col 37}{space 1} -15.16{col 46}{space 3}0.000{col 54}{space 4} .0421358{col 67}{space 3} .0870026 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. testparm i.agec {p 0 7}{space 1}{text:( 1)}{space 1} {res}[chd69]1.agec = 0{p_end} {p 0 7}{space 1}{text:( 2)}{space 1} [chd69]2.agec = 0{p_end} {p 0 7}{space 1}{text:( 3)}{space 1} [chd69]3.agec = 0{p_end} {p 0 7}{space 1}{text:( 4)}{space 1} [chd69]4.agec = 0{p_end} {txt}{col 12}chi2( 4) ={res} 44.08 {txt}{col 10}Prob > chi2 = {res} 0.0000 {txt} {com}. contrast q(1).agec, 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} chi2{col 38} P>chi2 {col 1}{text}{hline 13}{c +}{hline 11}{hline 12}{hline 11} {space 8}agec {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 31.45{col 38}{space 2} 0.0000 {col 1}{text}{hline 13}{c BT}{hline 11}{hline 12}{hline 11} {com}. test -1.agec + 3.agec + 2*4.agec=0 {p 0 7}{space 1}{text:( 1)}{space 1}{space 1}{res}- [chd69]1.agec + [chd69]3.agec + 2{res}*{res}[chd69]4.agec = 0{p_end} {txt}{col 12}chi2( 1) ={res} 31.45 {txt}{col 10}Prob > chi2 = {res} 0.0000 {txt} {com}. * evaluate evidence for departue from linearity . contrast q(2/4).agec, 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} chi2{col 38} P>chi2 {col 1}{text}{hline 13}{c +}{hline 11}{hline 12}{hline 11} {space 8}agec {c |} (quadratic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 0.33{col 38}{space 2} 0.5647 {txt} (cubic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 3.67{col 38}{space 2} 0.0555 {txt} (quartic) {col 14}{text}{c |}{result}{space 2} 1{col 26}{space 3} 1.62{col 38}{space 2} 0.2032 {col 1}{text} Joint {col 14}{c |}{result}{space 2} 3{col 26}{space 3} 5.29{col 38}{space 2} 0.1518 {col 1}{text}{hline 13}{c BT}{hline 11}{hline 12}{hline 11} {com}. . lincom 3.agec-2.agec {p 0 7}{space 1}{text:( 1)}{space 1}{space 1}{res}- [chd69]2.agec + [chd69]3.agec = 0{p_end} {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} chd69{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 9}(1) {c |}{col 14}{res}{space 2} 1.363777{col 26}{space 2} .2488687{col 37}{space 1} 1.70{col 46}{space 3}0.089{col 54}{space 4} .9537{col 67}{space 3} 1.95018 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. logistic chd69 ib2.agec {res} {txt}Logistic regression{col 51}Number of obs{col 67}= {res} 3154 {txt}{col 51}LR chi2({res}4{txt}){col 67}= {res} 44.95 {txt}{col 51}Prob > chi2{col 67}= {res} 0.0000 {txt}Log likelihood = {res}-868.14866{txt}{col 51}Pseudo R2{col 67}= {res} 0.0252 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} chd69{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 8}agec {c |} {space 6}36-40 {c |}{col 14}{res}{space 2} .5881696{col 26}{space 2} .131476{col 37}{space 1} -2.37{col 46}{space 3}0.018{col 54}{space 4} .379516{col 67}{space 3} .9115388 {txt}{space 6}41-45 {c |}{col 14}{res}{space 2} .5157198{col 26}{space 2} .0963491{col 37}{space 1} -3.54{col 46}{space 3}0.000{col 54}{space 4} .3575926{col 67}{space 3} .7437707 {txt}{space 6}51-55 {c |}{col 14}{res}{space 2} 1.363777{col 26}{space 2} .2488687{col 37}{space 1} 1.70{col 46}{space 3}0.089{col 54}{space 4} .9537{col 67}{space 3} 1.95018 {txt}{space 6}56-60 {c |}{col 14}{res}{space 2} 1.697642{col 26}{space 2} .3734367{col 37}{space 1} 2.41{col 46}{space 3}0.016{col 54}{space 4} 1.103073{col 67}{space 3} 2.612692 {txt}{space 12} {c |} {space 7}_cons {c |}{col 14}{res}{space 2} .1029412{col 26}{space 2} .0129216{col 37}{space 1} -18.11{col 46}{space 3}0.000{col 54}{space 4} .0804902{col 67}{space 3} .1316544 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. . * lowess fit & linear logistic model for age as continuous . . lowess chd69 age, bw(0.5) logit generate(chdsm) name(age_lws) {res}{txt} {com}. logistic chd69 age {res} {txt}Logistic regression{col 51}Number of obs{col 67}= {res} 3154 {txt}{col 51}LR chi2({res}1{txt}){col 67}= {res} 42.89 {txt}{col 51}Prob > chi2{col 67}= {res} 0.0000 {txt}Log likelihood = {res}-869.17806{txt}{col 51}Pseudo R2{col 67}= {res} 0.0241 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} chd69{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 9}age {c |}{col 14}{res}{space 2} 1.077262{col 26}{space 2} .0121757{col 37}{space 1} 6.58{col 46}{space 3}0.000{col 54}{space 4} 1.05366{col 67}{space 3} 1.101392 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .0026333{col 26}{space 2} .0014465{col 37}{space 1} -10.81{col 46}{space 3}0.000{col 54}{space 4} .0008973{col 67}{space 3} .0077283 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. logistic chd69 age, coef {res} {txt}Logistic regression{col 51}Number of obs{col 67}= {res} 3154 {txt}{col 51}LR chi2({res}1{txt}){col 67}= {res} 42.89 {txt}{col 51}Prob > chi2{col 67}= {res} 0.0000 {txt}Log likelihood = {res}-869.17806{txt}{col 51}Pseudo R2{col 67}= {res} 0.0241 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} chd69{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 9}age {c |}{col 14}{res}{space 2} .0744226{col 26}{space 2} .0113024{col 37}{space 1} 6.58{col 46}{space 3}0.000{col 54}{space 4} .0522702{col 67}{space 3} .0965749 {txt}{space 7}_cons {c |}{col 14}{res}{space 2}-5.939516{col 26}{space 2} .5493226{col 37}{space 1} -10.81{col 46}{space 3}0.000{col 54}{space 4}-7.016168{col 67}{space 3}-4.862863 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. predict lp, xb {txt} {com}. . * generate spline basis and fit model . mkspline agesp=age, cubic {txt} {com}. logistic chd69 agesp* {res} {txt}Logistic regression{col 51}Number of obs{col 67}= {res} 3154 {txt}{col 51}LR chi2({res}4{txt}){col 67}= {res} 51.10 {txt}{col 51}Prob > chi2{col 67}= {res} 0.0000 {txt}Log likelihood = {res}-865.07152{txt}{col 51}Pseudo R2{col 67}= {res} 0.0287 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} chd69{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} .7544048{col 26}{space 2} .1099386{col 37}{space 1} -1.93{col 46}{space 3}0.053{col 54}{space 4} .5669696{col 67}{space 3} 1.003805 {txt}{space 6}agesp2 {c |}{col 14}{res}{space 2} 32.42387{col 26}{space 2} 52.31911{col 37}{space 1} 2.16{col 46}{space 3}0.031{col 54}{space 4} 1.372041{col 67}{space 3} 766.236 {txt}{space 6}agesp3 {c |}{col 14}{res}{space 2} .0003586{col 26}{space 2} .0014684{col 37}{space 1} -1.94{col 46}{space 3}0.053{col 54}{space 4} 1.17e-07{col 67}{space 3} 1.096005 {txt}{space 6}agesp4 {c |}{col 14}{res}{space 2} 140.6726{col 26}{space 2} 454.3082{col 37}{space 1} 1.53{col 46}{space 3}0.126{col 54}{space 4} .2507358{col 67}{space 3} 78922.78 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} 4251.682{col 26}{space 2} 24861.72{col 37}{space 1} 1.43{col 46}{space 3}0.153{col 54}{space 4} .0447876{col 67}{space 3} 4.04e+08 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. predict lps, xb {txt} {com}. . * test for nonlinearity of log outcome odds in age . test agesp2 agesp3 agesp4 {p 0 7}{space 1}{text:( 1)}{space 1} {res}[chd69]agesp2 = 0{p_end} {p 0 7}{space 1}{text:( 2)}{space 1} [chd69]agesp3 = 0{p_end} {p 0 7}{space 1}{text:( 3)}{space 1} [chd69]agesp4 = 0{p_end} {txt}{col 12}chi2( 3) ={res} 8.07 {txt}{col 10}Prob > chi2 = {res} 0.0446 {txt} {com}. . twoway (connected chdsm age, sort msymbol(none)) (connected lp age, sort msymbol(none)) (connected lps age, sort msymbol(none)), legend(order(1 2 3) label(1 "lowess") label(2 "linear") label(3 "spline") pos(6) ring(0)) name(chdage_pr) {res}{txt} {com}. . tabodds chd69 age, ciplot {res} {txt}{hline 12}{c TT}{hline 61} age {c |} cases controls odds [95% Conf. Interval] {hline 12}{c +}{hline 61} {col 3} 39 {c |} {res} 19 247 0.07692 0.04824 0.12266 {txt}{col 3} 40 {c |} {res} 12 265 0.04528 0.02539 0.08075 {txt}{col 3} 41 {c |} {res} 12 221 0.05430 0.03037 0.09707 {txt}{col 3} 42 {c |} {res} 5 217 0.02304 0.00949 0.05592 {txt}{col 3} 43 {c |} {res} 13 202 0.06436 0.03673 0.11276 {txt}{col 3} 44 {c |} {res} 13 222 0.05856 0.03347 0.10244 {txt}{col 3} 45 {c |} {res} 12 174 0.06897 0.03842 0.12379 {txt}{col 3} 46 {c |} {res} 11 159 0.06918 0.03755 0.12746 {txt}{col 3} 47 {c |} {res} 8 139 0.05755 0.02822 0.11737 {txt}{col 3} 48 {c |} {res} 19 145 0.13103 0.08123 0.21138 {txt}{col 3} 49 {c |} {res} 21 113 0.18584 0.11665 0.29608 {txt}{col 3} 50 {c |} {res} 11 124 0.08871 0.04788 0.16435 {txt}{col 3} 51 {c |} {res} 17 106 0.16038 0.09611 0.26763 {txt}{col 3} 52 {c |} {res} 15 98 0.15306 0.08889 0.26355 {txt}{col 3} 53 {c |} {res} 12 93 0.12903 0.07073 0.23539 {txt}{col 3} 54 {c |} {res} 11 96 0.11458 0.06140 0.21383 {txt}{col 3} 55 {c |} {res} 10 70 0.14286 0.07365 0.27712 {txt}{col 3} 56 {c |} {res} 12 64 0.18750 0.10121 0.34735 {txt}{col 3} 57 {c |} {res} 7 56 0.12500 0.05697 0.27425 {txt}{col 3} 58 {c |} {res} 6 50 0.12000 0.05145 0.27986 {txt}{col 3} 59 {c |} {res} 11 36 0.30556 0.15554 0.60026 {txt}{hline 12}{c BT}{hline 61} Test of homogeneity (equal odds): chi2({res}20{txt}) = {res} 72.98 {txt}Pr>chi2 = {res} 0.0000 {txt}Score test for trend of odds: chi2({res}1{txt}) = {res} 44.85 {txt}Pr>chi2 = {res} 0.0000 {txt} {com}. . . * generate distinct levels of age . levelsof age {txt}39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 {com}. . * generate log-odds estimates and pointwise 95% CI for unique ages based on the previously fitted spline model, save results as new variables for graphing ("x" represents age) . xblc agesp*, covname(age) at(`r(levels)') generate(x losp lolb loub) {col 1}age{col 15}xb{col 26}(95% CI) {txt}{col 1}39{col 15}-2.64{col 25} (-3.06--2.21) {col 1}40{col 15}-2.91{col 25} (-3.19--2.62) {col 1}41{col 15}-3.11{col 25} (-3.43--2.79) {col 1}42{col 15}-3.19{col 25} (-3.56--2.82) {col 1}43{col 15}-3.10{col 25} (-3.43--2.77) {col 1}44{col 15}-2.90{col 25} (-3.16--2.63) {col 1}45{col 15}-2.67{col 25} (-2.94--2.40) {col 1}46{col 15}-2.48{col 25} (-2.77--2.19) {col 1}47{col 15}-2.33{col 25} (-2.60--2.07) {col 1}48{col 15}-2.22{col 25} (-2.45--2.00) {col 1}49{col 15}-2.14{col 25} (-2.35--1.93) {col 1}50{col 15}-2.07{col 25} (-2.30--1.85) {col 1}51{col 15}-2.02{col 25} (-2.26--1.78) {col 1}52{col 15}-1.97{col 25} (-2.21--1.73) {col 1}53{col 15}-1.93{col 25} (-2.16--1.70) {col 1}54{col 15}-1.89{col 25} (-2.10--1.68) {col 1}55{col 15}-1.86{col 25} (-2.07--1.64) {col 1}56{col 15}-1.83{col 25} (-2.07--1.58) {col 1}57{col 15}-1.80{col 25} (-2.10--1.49) {col 1}58{col 15}-1.77{col 25} (-2.15--1.39) {col 1}59{col 15}-1.74{col 25} (-2.20--1.28) {com}. . * plot, with style options suitable for printing/presentation . twoway (rarea lolb loub x, color(gray)) (connected losp x, sort msymbol(none) color(black) lpattern(solid)) , xtitle("Age") ytitle("Log Odds of CHD") legend(order(2 1) label(1 "95% CI") label(2 "Log odds") pos(5) ring(0) region(lwidth(none))) plotregion(style(none)) scheme(s1mono) name(chdage_lsp) {res}{txt} {com}. . * convert to probability scale from log odds . gen prsp = exp(losp)/(1 + exp(losp)) {txt}(3133 missing values generated) {com}. gen plb = exp(lolb)/(1 + exp(lolb)) {txt}(3133 missing values generated) {com}. gen pub = exp(loub)/(1 + exp(loub)) {txt}(3133 missing values generated) {com}. twoway (rarea plb pub x, color(gray)) (connected prsp x, sort msymbol(none) color(black) lpattern(solid)) , xtitle("Age") ytitle("Probability CHD") legend(order(2 1) label(1 "95% CI") label(2 "Probability") pos(6) ring(0) region(lwidth(none))) plotregion(style(none)) scheme(s1mono) name(chdage_psp) {res}{txt} {com}. graph export pr_age_sp.pdf, replace {txt}(file /Users/steve/Documents/teaching/c2015/biostat208/labs/lab8/pr_age_sp.pdf written in PDF format) {com}. . log close {txt}name: {res} {txt}log: {res}/Users/steve/Documents/teaching/c2015/biostat208/labs/lab8/lab8.smcl {txt}log type: {res}smcl {txt}closed on: {res}26 Feb 2015, 10:02:01 {txt}{.-} {smcl} {txt}{sf}{ul off}