Categorical Data Analysis: Chapter 9
options nodate nonumber ps=200 ls=80 formdlim=' ';
data arthritis;
length treatment $7. sex $6.;
input sex $ treatment $ improve $ count @@;
datalines;
female active marked 16 female active some 5 female active none 6
female placebo marked 6 female placebo some 7 female placebo none 19
male active marked 5 male active some 2 male active none 7
male placebo marked 1 male placebo some 0 male placebo none 10
;
run;
proc logistic order=data;
freq count;
class treatment sex / param=reference;
model improve = sex treatment / scale=none aggregate;
run;
proc logistic order=data;
freq count;
class sex treatment / param=reference;
model improve = sex treatment sex*treatment /
selection=forward start=2;
run;
data respire;
input air $ exposure $ smoking $ level count @@;
datalines;
low no non 1 158 low no non 2 9
low no ex 1 167 low no ex 2 19
low no cur 1 307 low no cur 2 102
low yes non 1 26 low yes non 2 5
low yes ex 1 38 low yes ex 2 12
low yes cur 1 94 low yes cur 2 48
high no non 1 94 high no non 2 7
high no ex 1 67 high no ex 2 8
high no cur 1 184 high no cur 2 65
high yes non 1 32 high yes non 2 3
high yes ex 1 39 high yes ex 2 11
high yes cur 1 77 high yes cur 2 48
low no non 3 5 low no non 4 0
low no ex 3 5 low no ex 4 3
low no cur 3 83 low no cur 4 68
low yes non 3 5 low yes non 4 1
low yes ex 3 4 low yes ex 4 4
low yes cur 3 46 low yes cur 4 60
high no non 3 5 high no non 4 1
high no ex 3 4 high no ex 4 3
high no cur 3 33 high no cur 4 36
high yes non 3 6 high yes non 4 1
high yes ex 3 4 high yes ex 4 2
high yes cur 3 39 high yes cur 4 51
;
run;
proc logistic descending;
freq count;
class air exposure(ref='no') smoking / param=reference;
model level = air exposure smoking
air*exposure air*smoking exposure*smoking /
selection=forward include=3 scale=none
aggregate=(air exposure smoking);
run;
data school;
input school program $ style $ count @@;
datalines;
1 regular self 10 1 regular team 17 1 regular class 26
1 after self 5 1 after team 12 1 after class 50
2 regular self 21 2 regular team 17 2 regular class 26
2 after self 16 2 after team 12 2 after class 36
3 regular self 15 3 regular team 15 3 regular class 16
3 after self 12 3 after team 12 3 after class 20
;
run;
proc catmod order=data;
weight count;
model style=school program school*program;
run;
proc catmod order=data;
weight count;
model style=school program;
run;
data survey;
input age sex race poverty function $ count @@;
datalines;
1 0 0 0 major 5.361 1 0 0 0 other 1.329 1 0 0 0 not 102.228
1 0 0 1 major 20.565 1 0 0 1 other 13.952 1 0 0 1 not 336.160
1 0 0 2 major 21.299 1 0 0 2 other 5.884 1 0 0 2 not 284.931
1 0 1 0 major 53.314 1 0 1 0 other 16.402 1 0 1 0 not 827.900
1 0 1 1 major 102.076 1 0 1 1 other 36.551 1 0 1 1 not 1518.796
1 0 1 2 major 52.338 1 0 1 2 other 21.105 1 0 1 2 not 666.909
1 1 0 0 major 1.172 1 1 0 0 other 1.199 1 1 0 0 not 87.292
1 1 0 1 major 11.169 1 1 0 1 other 2.945 1 1 0 1 not 304.234
1 1 0 2 major 15.286 1 1 0 2 other 3.665 1 1 0 2 not 302.511
1 1 1 0 major 21.882 1 1 1 0 other 16.979 1 1 1 0 not 846.270
1 1 1 1 major 52.354 1 1 1 1 other 33.106 1 1 1 1 not 1452.895
1 1 1 2 major 28.203 1 1 1 2 other 11.455 1 1 1 2 not 687.109
2 0 0 0 major .915 2 0 0 0 other 1.711 2 0 0 0 not 91.071
2 0 0 1 major 12.591 2 0 0 1 other 8.026 2 0 0 1 not 326.930
2 0 0 2 major 21.059 2 0 0 2 other 6.993 2 0 0 2 not 313.633
2 0 1 0 major 36.384 2 0 1 0 other 27.558 2 0 1 0 not 888.833
2 0 1 1 major 85.974 2 0 1 1 other 42.755 2 0 1 1 not 1509.87
2 0 1 2 major 40.112 2 0 1 2 other 23.493 2 0 1 2 not 725.004
2 1 0 0 major 5.876 2 1 0 0 other 2.550 2 1 0 0 not 115.968
2 1 0 1 major 8.772 2 1 0 1 other 6.922 2 1 0 1 not 344.076
2 1 0 2 major 17.385 2 1 0 2 other 2.354 2 1 0 2 not 286.68
2 1 1 0 major 42.741 2 1 1 0 other 31.025 2 1 1 0 not 817.478
2 1 1 1 major 72.688 2 1 1 1 other 35.979 2 1 1 1 not 1499.816
2 1 1 2 major 26.296 2 1 1 2 other 29.321 2 1 1 2 not 716.860
;
run;
proc catmod order=data;
direct poverty;
weight count;
model function=age|sex|race|poverty@2;
run;
proc catmod order=data;
direct poverty;
weight count;
model function=age sex race poverty
age*sex sex*race race*poverty;
run;
proc catmod order=data;
direct poverty;
weight count;
model function=age sex race poverty
age*sex race*poverty /pred=freq;
run;
Statistics and Operations Research