[i] \$c This was prepared for Class 5, Soc. 619, Fall 1993 [i] \$C Data from Clogg, Table 5 [i] \$C [i] \$UNITS 20 \$DATA FREQ \$READ [i] 44 11 38 62 [i] 59 41 147 293 [i] 23 11 13 27 [i] 27 8 16 27 [i] 258 57 105 110 [i] \$CAL %r=5 [i] \$CAL %c=4 [i] \$var %r mu \$var %c nu \$ [i] \$calc mu=%GL(%r,1) [i] \$CAL nu=%GL(%c,1) !initital parameter estimates \$ [i] [i] \$macro RC ! [i] \$delete r_ c_ m1_ m2_ f1_ f2_ f3_ n1_ n2_ n3_ df_ beta \$ [i] \$warn ! [i] \$calc %z1=%if(%gt(%w,0),%w,10) \$ [i] \$calc r_=%gl(%r,%c) : c_=%gl(%c,1) : %h=0 : %d=0 \$ [i] \$var 1 df_ \$ [i] \$factor r_ %r c_ %c \$ [i] \$calc %z=1 : %z2=%coc \$ [i] \$calc f2_=%yv : n3_=0 \$ [i] \$print : 'Deviance df Iteration Change' \$ [i] \$while %z frc \$ [i] \$delete df_ f1_ f2_ f3_ m1_ m2_ n1_ n2_ n3_ r_ c_ beta \$ [i] \$warn ! [i] \$endmac ! [i] ! [i] \$macro frc ! [i] \$warn \$ [i] \$out \$tran \$ [i] \$calc n2_=nu(c_) \$ [i] \$fit #linp+r_.n2_ \$ [i] \$var %pl m1_ \$ [i] \$extract %pe \$calc m1_=%pe \$ [i] \$calc %m=%pl-%r \$ [i] \$calc mu=%gl(%r,1) : mu(mu)=m1_(mu+%m) : m2_=mu(r_) \$ [i] \$fit #linp+c_.m2_ \$ [i] \$calc %h=%h+1 \$ [i] \$var %pl n1_ \$ [i] \$extract %pe \$calc n1_=%pe \$ [i] \$calc nu=%gl(%c,1) : %o=%pl-%c : nu(nu)=n1_(nu+%o) \$ [i] \$calc f1_=f2_ : f2_=%fv \$ [i] \$calc f3_=(f2_-f1_)**2 \$ [i] \$sort n3_ f3_ \$calc %d=n3_(%nu) \$ [i] \$calc %d=%sqrt(%d) \$ [i] \$out %z2 \$tran i o \$ [i] \$use depr \$ [i] \$calc %d=%lt(%d,0.001) \$ [i] \$switch %d last \$ [i] \$calc %e=%ge(%h,%z1) \$ [i] \$switch %e drop \$ [i] \$warn \$ [i] \$endmac ! [i] ! [i] \$macro depr ! [i] \$calc df_=(%r-2)*(%c-2) \$ [i] \$print *r %dv,8,3 *i df_,7 *i %h,10 *r %d,15,3 \$ [i] \$endmac [i] ! [i] \$macro drop ! [i] \$print ;'ALGORITHM DID NOT CONVERGE IN '*i %z1,4 ' CYCLES OF ITERATIONS' ! [i] \$print ' '\$ [i] \$calc %z=0 \$ [i] \$endmac ! [i] ! [i] \$macro last ! [i] \$warn \$ [i] \$print ' ' ! [i] \$print 'ROW SCORES' ! [i] \$calc %x=%cu(mu)/%r : mu=mu-%x : %x=%cu(mu**2) : mu=mu/%sqrt(%x) ! [i] \$calc %y=%cu(nu)/%c : nu=nu-%y : %y=%cu(nu**2) : nu=nu/%sqrt(%y) ! [i] \$look mu ! [i] \$print ' ' ! [i] \$print 'COLUMN SCORES' ! [i] \$look nu ! [i] \$calc m2_=mu(r_) : n2_=nu(c_) : %h=0 ! [i] \$print ;'Standard errors and d.f. given below are not valid. ' [i] \$print 'Correct d.f. = ' *i df_,3\$ [i] \$print ;' ' \$ [i] \$calc beta=m2_*n2_ : %z=0 \$fit r_+c_+beta \$dis e ! [i] \$warn ! [i] \$endmac ! [i] ! [i] \$macro linp r_+c_ \$endmacro [i] \$error p [i] \$yvar freq [i] \$c Independence model [i] \$calc r_=%gl(%r,%c) : c_=%gl(%c,1) [i] \$factor r_ %r c_ %c \$ [i] \$fit r_+ c_ [i] \$disp e\$ [o] scaled deviance = 236.34 at cycle 4 [o] d.f. = 12 [o] [o] estimate s.e. parameter [o] 1 3.834 0.09032 1 [o] 2 1.248 0.09112 R_(2) [o] 3 -0.7394 0.1413 R_(3) [o] 4 -0.6867 0.1388 R_(4) [o] 5 1.229 0.09131 R_(5) [o] 6 -1.167 0.1012 C_(2) [o] 7 -0.2534 0.07462 C_(3) [o] 8 0.2333 0.06603 C_(4) [o] scale parameter taken as 1.000 [o] [i] \$use rc \$ [w] -- deletion affects model [o] [o] Deviance df Iteration Change [o] 5.726 6 1 5.160 [o] 5.558 6 2 1.383 [o] 5.557 6 3 0.072 [o] 5.557 6 4 0.004 [o] 5.557 6 5 0.000 [o] [o] ROW SCORES [o] MU [o] 1 0.07529 [o] 2 0.77632 [o] 3 -0.09830 [o] 4 -0.15502 [o] 5 -0.59830 [o] [o] COLUMN SCORES [o] NU [o] 1 -0.7432 [o] 2 -0.1265 [o] 3 0.2713 [o] 4 0.5984 [o] [o] Standard errors and d.f. given below are not valid. [o] Correct d.f. = 6 [o] [o] [o] scaled deviance = 5.5574 at cycle 3 [o] d.f. = 11 [o] [o] estimate s.e. parameter [o] 1 3.795 0.09340 1 [o] 2 1.060 0.09471 R_(2) [o] 3 -0.7277 0.1413 R_(3) [o] 4 -0.6747 0.1389 R_(4) [o] 5 1.182 0.09287 R_(5) [o] 6 -1.039 0.1040 C_(2) [o] 7 -0.1592 0.07987 C_(3) [o] 8 0.2275 0.07215 C_(4) [o] 9 1.308 0.09405 BETA [o] scale parameter taken as 1.000 [o] [i] \$stop