Monday, April 20, 2009

cross over design (binary output)

data crossover;
input group $ seq1 seq2 count;
seq='(' || put(seq1,1.) || ',' || put(seq2,1.) || ')';
diff=seq2-seq1;
trt=diff*(group='1(AB)') - diff*(group='2(BA)');
ig=-trt;
datalines;
1(AB) 0 0 5
1(AB) 0 1 14
1(AB) 1 0 3
1(AB) 1 1 6
2(BA) 0 0 10
2(BA) 0 1 7
2(BA) 1 0 18
2(BA) 1 1 10
;

proc freq;
weight count;
table group*seq1*seq2;
run;

/* Odds Ratio */
* carry-over effect;
proc freq data=crossover (where=(diff=0));
weight count;
table group*seq / chisq;
run;
proc freq data=crossover (where=(diff ne 0));
weight count;
table group*seq / chisq;
run;

proc logistic data=crossover (where=(diff ne 0));
weight count;
class group;
model diff = group;
run;

/* Prescott's test */
proc freq data=crossover;
weight count;
table group*diff / chisq;
run;

/*** McNemar's test ***/
* 1(AB);
proc freq data=crossover (where=(group="1(AB)"));
weight count;
table seq1*seq2 / agree;
run;
proc logistic data=crossover (where=(group="1(AB)" & diff ne 0));
weight count;
model diff =;
run;

* 2(BA);
proc freq data=crossover (where=(group="2(BA)"));
weight count;
table seq1*seq2 / agree;
run;
proc logistic data=crossover (where=(group="2(BA)" & diff ne 0));
weight count;
model diff =;
run;

* group differ ;
proc freq data=crossover (where=(diff ne 0));
weight count;
table ig*trt / agree;
run;