/************************************************************* Example of nominal model for grouped data Powers & Xie, (1st edition), page237 With modificactions for edps/psy/sco 589 *************************************************************/ /* blk = 0 if white/other 1 if black fcol= 0 if Father's education <=12 yr 1 if Father's education >12 yr */ data a; input empl blk fcol freq; nempl=2; /* empl=0 */ if empl=0 then nempl=3; * Not working; if empl=1 then nempl=2; * Working; if empl=2 then nempl=1; * In school; empl=nempl; cards; 0 0 0 131 0 0 1 28 0 1 0 67 0 1 1 9 1 0 0 195 1 0 1 90 1 1 0 53 1 1 1 5 2 0 0 204 2 0 1 78 2 1 0 100 2 1 1 18 ; /****************************** blk and fcol are dummy coded *******************************/ /* Null Model */ title 'Null (logit model)'; proc genmod ; class empl ; model freq = blk fcol empl blk*fcol /dist=poisson link=log type3; /*blk Effect Model */ title 'Race effects logit model at loglinear'; proc genmod; class empl ; model freq= blk fcol empl blk*fcol blk*empl /dist=poisson link=log type3; /*race Effects Model */ title 'Father education effects logit model at loglinear'; proc genmod; class empl ; model freq= blk fcol empl blk*fcol fcol*empl /dist=poisson link=log type3; run; /*Main Effects Model */ title 'Main effects logit model at loglinear'; proc genmod; class empl ; model freq= blk fcol empl blk*fcol blk*empl fcol*empl /dist=poisson link=log type3; run; /* Saturated Model */ title 'Saturated model'; proc genmod; class empl ; model freq= blk fcol empl blk*fcol blk*empl fcol*empl blk*fcol*empl /dist=poisson link=log type3; run; data pvalues; pR = 1-cdf('chisquare',12.4426,4); pF = 1-cdf('chisquare',23.8428,4); pRF =1-cdf('chisquare',3.6659,2); pnull=1-cdf('chisquare',35.7151,6); run; proc print; run; /*************************************************************************** Proportional Odds ***************************************************************************/ title 'Proportional Odds Model'; proc logistic data=a; weight freq; model nempl = blk fcol ; run; /**************************************************************************** Continuation Ratios ****************************************************************************/ /* nempl=3; * Not working; nempl=2; * Working; nempl=1; * In school; */ data cr1_2; set a; if nempl=3 then delete; run; /**********/ title 'Null: In school (1) vs Working'; proc logistic data=cr1_2; class blk fcol; weight freq; model nempl = / lackfit; run; proc genmod data=cr1_2; class blk fcol nempl; model freq = blk fcol blk*fcol nempl / link=log dist=poi type3; run; title 'Father edu: In school (1) vs Working'; proc logistic data=cr1_2; class blk fcol; weight freq; model nempl = fcol / lackfit; run; proc genmod data=cr1_2; class blk fcol nempl; model freq = blk fcol blk*fcol nempl nempl*fcol / link=log dist=poi type3; run; title 'Black: In school (1) vs Working'; proc logistic data=cr1_2; class blk fcol; weight freq; model nempl = blk / lackfit; run; proc genmod data=cr1_2; class blk fcol nempl; model freq = blk fcol blk*fcol nempl nempl*blk / link=log dist=poi type3; run; title 'BK + FCOL: Modeling In school (1) vs Working'; proc logistic data=cr1_2; class blk fcol; weight freq; model nempl = blk fcol / link=glogit; run; proc genmod data=cr1_2; class blk fcol nempl; model freq = blk fcol blk*fcol nempl nempl*blk nempl*fcol / link=log dist=poi type3; run; /**********/ data cr12_3; set a; if nempl=1 or nempl=2 then nempl=1; run; proc freq data=cr12_3; weight freq; tables nempl*blk*fcol /nopercent norow nocol out=logit2; run; title 'Null Modeling School or Working (2) vs Not Working'; proc logistic data=logit2; class blk fcol; weight count; model nempl = / link=glogit; run; proc genmod data=logit2; class blk fcol nempl; model count = blk fcol blk*fcol nempl / link=log dist=poi type3; run; title 'FCOL Modeling School or Working (2) vs Not Working'; proc logistic data=logit2; class blk fcol; weight count; model nempl = fcol / link=glogit; run; proc genmod data=logit2; class blk fcol nempl; model count = blk fcol blk*fcol nempl nempl*fcol / link=log dist=poi type3; run; title 'BLK: Modeling School or Working (2) vs Not Working'; proc logistic data=logit2; class blk fcol; weight count; model nempl = blk / link=glogit; run; proc genmod data=logit2; class blk fcol nempl; model count = blk fcol blk*fcol nempl nempl*blk / link=log dist=poi type3; run; data pvalues; p1 = 1 - cdf('chisquare',16.5575,3); p2 = 1 - cdf('chisquare',9.7941,2); p3 = 1 - cdf('chisquare',6.0043,2); p4 = 1 - cdf('chisquare',1.3512,1); pa = 1 - cdf('chisquare',19.1576,3); pb = 1 - cdf('chisquare',17.8385,2); pc = 1 - cdf('chisquare',2.6484,2); pd = 1 - cdf('chisquare',2.3879,1); delta = 1 - cdf('chisquare',4.6531,1); global =1 - cdf('chisquare',3.7391,3); run; title 'BLK +FCOL Modeling School or Working (2) vs Not Working'; proc logistic data=logit2; class blk fcol; weight count; model nempl = blk fcol / link=glogit; run; proc genmod data=logit2; class blk fcol nempl; model count = blk fcol blk*fcol nempl nempl*blk nempl*fcol / link=log dist=poi type3; run;