Thursday, April 23, 2009

Poisson vs. Logistic regression


data melanoma;
input age $ region $ cases total;
ltotal=log(total);
datalines;
35-44 south 75 220407
45-54 south 68 198119
55-64 south 63 134084
65-74 south 45 70708
75+ south 27 34233
<35 south 64 1074246
35-44 north 76 564535
45-54 north 98 592983
55-64 north 104 450740
65-74 north 63 270908
75+ north 80 161850
<35 north 61 2880262
;
proc genmod data=melanoma order=data;
class age region;
model cases = age region / dist=poisson link=log offset=ltotal;
run;

proc sql;
create table melanoma2 as
select age, region, 1 as resp, cases as count from melanoma union
select age, region, 0 as resp, total-cases as count from melanoma
;quit;

proc genmod data=melanoma2;
weight count;
class age region;
model resp=age region / dist=binomial link=logit;
run;

proc mixed


data bond;
input ingot metal $ pres @@;
datalines;
1 n 67.0 1 i 71.9 1 c 72.2
2 n 67.5 2 i 68.8 2 c 66.4
3 n 76.0 3 i 82.6 3 c 74.5
4 n 72.7 4 i 78.1 4 c 67.3
5 n 73.1 5 i 74.2 5 c 73.2
6 n 65.8 6 i 70.8 6 c 68.7
7 n 75.6 7 i 84.9 7 c 69.0
;

proc mixed data=bond method=reml;
class ingot metal;
model pres=metal;
random ingot;
lsmeans metal / diff=control('n') adjust=dunnett;
run;

/* by simulation */
lsmeans metal / diff=control("n") cl
adjust=simulate(report seed=4943838 cvadjust);