window push log using 5.20.EsophagealCa.ClassVersion.log, replace window push set more on window push * 5.20.EsophagealCa.ClassVersionlog window push * window push * Regress esophageal cancers against age and dose of alcohol window push * and tobacco using a multiplicative model. window push * window push use 5.5.EsophagealCa.dta, clear window push sort tobacco window push by tobacco: tabulate cancer alcohol [freq=patients] , column window push * window push * Combine tobacco levels 2 and 3 in a new variable called smoke window push * window push generate smoke = tobacco window push recode smoke 3=2 4=3 window push label variable smoke "Smoking (gm/day)" window push label define smoke 1 "0-9" 2 "10-29" 3 ">= 30" window push label values smoke smoke window push table smoke tobacco [freq=patients], row col window push * window push * Regress cancer against age, alcohol and smoke window push * using a multiplicative model window push * window push logistic cancer i.age i.alcohol i.smoke [freq=patients] window push lincom 2.alcohol + 2.smoke, or window push lincom 3.alcohol + 2.smoke, or window push lincom 4.alcohol + 2.smoke, or window push lincom 2.alcohol + 3.smoke, or window push lincom 3.alcohol + 3.smoke, or window push lincom 4.alcohol + 3.smoke, or window push * window push * Regress cancer against age, alcohol and smoke. window push * Include alcohol-smoke interaction terms. window push * window push logistic cancer i.age alcohol##smoke [freq=patients] window push lincom 2.alcohol + 2.smoke + 2.alcohol#2.smoke, or window push lincom 2.alcohol + 3.smoke + 2.alcohol#3.smoke, or window push lincom 3.alcohol + 2.smoke + 3.alcohol#2.smoke, or window push lincom 3.alcohol + 3.smoke + 3.alcohol#3.smoke, or window push lincom 4.alcohol + 2.smoke + 4.alcohol#2.smoke, or window push lincom 4.alcohol + 3.smoke + 4.alcohol#3.smoke, or window push * window push * Calculate delta deviance window push * window push display 2*( 351.96823 -349.29335 ) window push display chi2tail(6, 5.34976) window push more window push * window push * Perform Pearson chi-squared and Hosmer-Lemeshow tests of window push * goodness of fit. window push * window push lfit window push lfit, group(10) table window push * window push * Perform residual analysis window push * window push predict p, p window push label variable p /// window push "Estimate of {&pi} for the j{superscript:th} Covariate Pattern" window push predict dx2, dx2 window push predict rstandard, rstandard window push generate dx2_pos = dx2 if rstandard >= 0 window push generate dx2_neg = dx2 if rstandard < 0 window push label variable dx2_pos "Positive residual" window push label variable dx2_neg "Negative residual" window push predict dbeta, dbeta window push scatter dx2_pos p [weight=dbeta] /// window push , msymbol(Oh) mlwidth(medthick) mcolor(red) /// window push || scatter dx2_neg p [weight=dbeta] /// window push , msymbol(Oh) mlwidth(medthick) mcolor(blue) /// window push ||, ylabel(0(1)8, angle(0)) /// window push ymtick(0(.5)8) yline(3.84, lwidth(medthick)) /// window push xlabel(0(.1)1) xmtick(0(.05)1) /// window push ytitle("Squared Standardized Pearson Residual") /// window push xscale(titlegap(2)) window push more window push save temporary, replace window push drop if patients == 0 window push generate ca_no = cancer*patients window push collapse (sum) n = patients ca = ca_no, by(age alcohol smoke dbeta dx2 p) window push * window push * Identify covariate patterns associated with large squared residuals window push * window push list n ca age alcohol smoke dbeta dx2 p if dx2 > 3.84, nodisplay window push * window push * Rerun analysis without the covariate pattern A window push * window push use temporary, clear window push drop if age == 4 & alcohol ==4 & smoke == 1 window push logistic cancer i.age i.alcohol##i.smoke [freq=patients] window push lincom 2.alcohol + 2.smoke + 2.alcohol#2.smoke, or window push lincom 2.alcohol + 3.smoke + 2.alcohol#3.smoke, or window push lincom 3.alcohol + 2.smoke + 3.alcohol#2.smoke, or window push lincom 3.alcohol + 3.smoke + 3.alcohol#3.smoke, or window push lincom 4.alcohol + 2.smoke + 4.alcohol#2.smoke, or window push lincom 4.alcohol + 3.smoke + 4.alcohol#3.smoke, or window push * window push * Rerun analysis without the covariate pattern B window push * window push use temporary, clear window push drop if age == 4 & alcohol ==1 & smoke == 3 window push logistic cancer i.age i.alcohol##i.smoke [freq=patients] window push lincom 2.alcohol + 2.smoke + 2.alcohol#2.smoke, or window push lincom 2.alcohol + 3.smoke + 2.alcohol#3.smoke, or window push lincom 3.alcohol + 2.smoke + 3.alcohol#2.smoke, or window push lincom 3.alcohol + 3.smoke + 3.alcohol#3.smoke, or window push lincom 4.alcohol + 2.smoke + 4.alcohol#2.smoke, or window push lincom 4.alcohol + 3.smoke + 4.alcohol#3.smoke, or window push log close