380 likes | 695 Views
10.4 Symmetry, Quasi-symmetry and Quasi-independence. SAS code:. data migrate; input then $ now $ count symm qi; datalines ; ne ne 11607 1 1 ne mw 100 2 5 ne s 366 3 5 ne w 124 4 5 mw ne 87 2 5 mw mw 13677 5 2 mw s 515 6 5
E N D
SAS code: data migrate; input then $ now $ count symm qi; datalines; ne ne 11607 1 1 ne mw 100 2 5 ne s 366 3 5 ne w 124 4 5 mw ne 87 2 5 mw mw 13677 5 2 mw s 515 6 5 mw w 302 7 5 s ne 172 3 5 s mw 225 6 5 s s 17819 8 3 s w 270 9 5 w ne 63 4 5 w mw 176 7 5 w s 286 9 5 w w 10192 10 4 ; symm - symmetry qi - quasi indep.
SAS modeling procgenmod; class then now; model count =then now / dist=poi link=log; run;/*independence DF=(4-1)+(4-1)=6, residual DF=9 */ procgenmod; class symm; model count = symm / dist=poi link=log; * symmetry DF=4-1+4*(4-1)/2=9, residual DF=6 ; procgenmod; class then now qi; model count = then now qi / dist=poi link=log; * quasi indep DF=(4-1)+(4-1)+(5-1)=10, residual DF=5 ; procgenmod; class then now symm; model count = symm then now / dist=poi link=log; *quasi symmetry DF=(4-1+4*(4-1)/2)+(4-1)=12, residual DF=3 ;
Quasi Symmetry model • data
10.4.7 Premarital and extramarital sex example revisited symm qi - quasi indep.
G2=402.2 DF=6 G2=1.36 DF=3 procgenmoddata=sex; class symm; model count = symm / dist=poi link=log; * symmetry; procgenmoddata=sex; class extramar premar symm; model count = symm extramar premar / dist=poi link=log; *QS; procgenmoddata=sex; class symm; model count = symm extramar premar / dist=poi link=log; * ordinal QS; procgenmoddata=sex; class extramar premar qi; model count = extramar premar qi / dist=poi link=log; * quasi indep; procgenmoddata=sex; class extramar premar; model count = extramar premar unif / dist=poi link=log; run;/*linear-linear association*/ procgenmoddata=sex; class symm; model count = symm tao/ dist=poi link=log; * conditional symmetry; procgenmoddata=sex; class extramar premar qi; model count = extramar premar unif qi/ dist=poi link=log;*quasi uniform association; run; G2=2.09 DF=5 G2=7.04 DF=5 G2=8.32 DF=8 G2=15.5 DF=5 G2=1.43 DF=4
procgenmoddata=sex; class symm; model count = symm extramar premar / dist=poi link=log; * ordinal QS;
data sex1; set sex; ub_a=extramar-premar; if extramar<premar then nab=count; else nab=0; run; procsql; createtable aa as select symm, sum(count) as tcount, max(nab) as n_ab,max(ub_a) as ub_ua, count(symm) as nsumm from sex1 groupby symm having nsumm=2; proclogisticdata=aa; model n_ab/tcount=ub_ua/ noint; run;
Data aa proc genmod data=aa; model n_ab/tcount=/dist=bin link=logit noint; run; /*equivalent to symmetry*/ proc genmod data=aa; model n_ab/tcount=/dist=bin link=logit; run; /*equivalent to conditional symmetry*/
ORDINAL MODELS: procgenmoddata=sex; class symm; model count = symm extramar premar / dist=poi link=log; * ordinal QS; procgenmoddata=sex; class extramar premar; model count = extramar premar unif / dist=poi link=log; run;/*linear-linear association*/ procgenmoddata=sex; class symm; model count = symm tao/ dist=poi link=log; * conditional symmetry; procgenmoddata=sex; class extramar premar qi; model count = extramar premar unif qi/ dist=poi link=log;*quasi uniform association; run; G2=2.09 DF=5 G2=8.32 DF=8 G2=15.5 DF=5 G2=1.43 DF=4
Models Summary of IXI table • Define two variables, such as symm - symmetry qi - quasi indepedence
procgenmoddata=sex; class symm; model count = symm / dist=poi link=log; * symmetry; procgenmoddata=sex; class extramar premar symm; model count = symm extramar premar / dist=poi link=log; *QS; procgenmoddata=sex; class extramar premar qi; model count = extramar premar qi / dist=poi link=log; * quasi indep;
procgenmoddata=sex; class symm; model count = symm extramar premar / dist=poi link=log; * ordinal QS; procgenmoddata=sex; class extramar premar; model count = extramar premar unif / dist=poi link=log; run;/*linear-linear association*/ procgenmoddata=sex; class extramar premar qi; model count = extramar premar unif qi/ dist=poi link=log;*quasi uniform association; run;
procgenmoddata=sex; class symm; model count = symm tao/ dist=poi link=log; * conditional symmetry; Note: symm - symmetry
Symmetry, Ordinal Quasi-symmetry, conditional symmetry • Logistic form
data sex1; set sex; ub_a=extramar-premar; if extramar<premar then nab=count; else nab=0; run; procsql; createtable aa as select symm, sum(count) as tcount, max(nab) as n_ab,max(ub_a) as ub_ua, count(symm) as nsumm from sex1 groupby symm having nsumm=2; proclogisticdata=aa; model n_ab/tcount=ub_ua/ noint; run; /*ordinal QS*/ procgenmoddata=aa; model n_ab/tcount=/dist=bin link=logit; run; /*conditional symmetry*/ procgenmoddata=aa; model n_ab/tcount=/dist=bin link=logit noint; run; /*equivalent to symmetry*/