* Logit Chapter drop _all use heart01, clear glm death anterior hcabg kk2 kk3 kk4 age2-age4, family(bin) nolog glm death anterior hcabg kk2 kk3 kk4 age2-age4, family(bin) ef irls nolog logistic death anterior hcabg kk2 kk3 kk4 age2-age4, nolog estat classification lroc, nograph lfit, group(10) table glm death anterior hcabg kk2 kk3 kk4 age2-age4, family(bin) ef irls nolog ereturn disp, eform(Odds Ratio) predict double p /* p = predicted probability */ replace anterior=anterior+1 /* increment anterior */ predict double p1 /* p1= pred prob with anterior+1 */ gen double or=(p1/(1-p1))/(p/(1-p)) /* Calculate ratio of odds */ summ or /* display odds ratio (anterior) */ replace anterior=anterior-1 logistic death anterior hcabg kk2 kk3 kk4 age2-age4, nolog lstand /* warsaw.dta created from this -input drop _all input age total menarche 9.21 376 0 10.21 200 0 10.58 93 0 10.83 120 2 11.08 90 2 11.33 88 5 11.58 105 10 11.83 111 17 12.08 100 16 12.33 93 29 12.58 100 39 12.83 108 51 13.08 99 47 13.33 106 67 13.58 105 81 13.83 117 88 14.08 98 79 14.33 97 90 14.58 120 113 14.83 102 95 15.08 122 117 15.33 111 107 15.58 94 92 15.83 114 112 17.58 1049 1049 end */ use warsaw, clear list generate proportion = menarche/total twoway scatter proportion age graph export menarcheplot.eps, replace glm menarche age, family(bin total) predict double phat replace phat = phat/total label var phat "Predicted proportion reaching menarche" twoway (scatter phat age, s(o)) (scatter proportion age, s(.)) graph export menarchefit.eps, replace generate equal = (_n-1)/24 twoway (scatter phat proportion) (line equal equal), ytitle("Predicted proportion") xtitle("Observed proportion") graph export menarchefitprop.eps, replace /* drop _all input yes no cons school union class 51 8 1 1 1 1 51 35 2 1 1 1 11 6 1 2 1 1 23 15 2 2 1 1 142 37 1 1 2 1 64 21 2 1 2 1 37 11 1 2 2 1 19 25 2 2 2 1 31 8 1 1 1 2 83 94 2 1 1 2 34 16 1 2 1 2 106 143 2 2 1 2 62 23 1 1 2 2 57 54 2 1 2 2 61 24 1 2 2 2 99 110 2 2 2 2 end * cons "cons" "not" * school "more" "min" * union "member" "none" * class "middle" "working" gen total = yes+no gen consnot = cons==2 gen schoolmin = school==2 gen unionnone = union==2 gen classwork = class==2 */ use eec, clear glm yes consnot schoolmin unionnone classwork, family(bin total) * now add interaction cons*class and then compare deviances gen consnotwork = consnot*classwork glm yes consnot schoolmin unionnone classwork consnotwork, family(bin total) display chi2tail(1,1.216)