Categorical Data Analysis: Chapter 9
data arthritis;
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
;
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;
proc logistic order=data plots=effect(polybar x=treatment*sex);
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
;
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 wrist;
input glove $ gender $ relief $ count @@;
datalines;
test female major 12 test female moderate 8 test female none 5
test male major 8 test male moderate 14 test male none 15
gell female major 5 gell female moderate 5 gell female none 9
gell male major 8 gell male moderate 4 gell male none 20
;
proc logistic order=data;
freq count;
class glove gender / param=reference order=data;
model relief= glove gender / scale=none aggregate;
run;
proc logistic order=data;
freq count;
class glove gender / param=reference order=data;
model relief = glove gender / link=clogit
scale=none aggregate unequalslopes;
pogender: test genderfemale_major=genderfemale_moderate;
poglove: test glovetest_major=glovetest_moderate;
run;
proc logistic order=data;
freq count;
class glove gender / param=reference order=data;
model relief= glove gender / scale=none aggregate unequalslopes=glove;
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
;
proc logistic order=data;
freq count;
class school (ref=first) program (ref=last) / param=ref;
model style= program school school*program / link=glogit
scale=none aggregate;
run;
proc logistic order=data;
freq count;
class school (ref=first) program (ref=last) / param=ref;
model style= program school / link=glogit
scale=none aggregate;
oddsratio school;
oddsratio program;
run;
data alligator;
input length choice $ @@;
datalines;
1.24 I 1.30 I 1.30 I 1.32 F 1.32 F 1.40 F 1.42 I 1.42 F
1.45 I 1.45 O 1.47 I 1.47 F 1.50 I 1.52 I 1.55 I 1.60 I
1.63 I 1.65 O 1.65 I 1.65 F 1.65 F 1.68 F 1.70 I 1.73 O
1.78 I 1.78 I 1.78 O 1.80 I 1.80 F 1.85 F 1.88 I 1.93 I
1.98 I 2.03 F 2.03 F 2.16 F 2.26 F 2.31 F 2.31 F 2.36 F
2.36 F 2.39 F 2.41 F 2.44 F 2.46 F 2.56 O 2.67 F 2.72 I
2.79 F 2.84 F 3.25 O 3.28 O 3.33 F 3.56 F 3.58 F 3.66 F
3.68 O 3.71 F 3.89 F
;
ods graphics on;
proc logistic data=alligator plots=effect;
model choice(order=data) = length length*length/
selection=forward include=1 link=glogit;
run;
ods graphics off;
data pt;
format therapy $11.;
input gender $ age $ therapy $ count @@;
datalines;
males adult machines 2 males senior machines 10
males adult freeweights 13 males senior freeweights 9
males adult bands 3 males senior bands 3
females adult machines 3 females senior machines 8
females adult freeweights 9 females senior freeweights 0
females adult bands 1 females senior bands 1
;
proc logistic data=pt;
freq count;
class gender(ref='females') age(ref='senior') / param=ref;
model therapy(ref='machines') = gender age / link=glogit scale=none aggregate;
run;
proc logistic data=pt;
freq count;
class gender(ref='females') age(ref='senior') / param=ref;
model therapy(ref='machines') = gender age / link=glogit;
exact gender age / joint estimate=both;
run;