*** This SPSS code extends the code provided by Robert Boik (1993) in his article "The Analysis of Two-Factor Interactions in Fixed effects Linear Models", Journal of *** Educational Statistics, 18, 1-40. In their article "Studentized Maximum Root Procedures for Coherent Analyses of Two-factor Fixed Effects Designs" (in press), *** Kevin Bird and Dusan Hadzi-Pavlovic consider more general families of product contrasts than the family of product interaction contrasts considered by Boik. *** This code allows SPSS to calculate maximal product contrasts and associated SMR tests statistics for each of three different (but overlapping) families *** of product contrasts. Family A(B) includes A simple, A main and AB interaction product contrasts, Family B(A) includes B simple, *** B main and AB interaction product contrasts, and family AB includes AB product interaction contrasts only. ************************************************ *** The SPSS data file should include variables named A (the first factor with levels coded as consecutive integers), B (the second factor with levels coded as *** consecutive integers) and Y (the dependent variable). *** If you prefer to use variable names other than Y, A and B, you will need to change the last line of this file. ************************************************ /*** File handles for GLM output /******************************* file handle COVB /name="tmp_covb.sav". file handle DESIGN /name="tmp_design.sav". /** Alternating Least Squares Computations /***************************************** define ALSLOOP(). compute MuSq = reshape(Mu,a,b). compute Psi = t(Ca)*MuSq*Cb. call svd(Psi,U,D,V). compute wp = U(:,1). compute Phi = t(Kroneker(Cb,Ca))*Sigma*Kroneker(Cb,Ca). compute Psi = reshape(t(Psi),p*q,1). compute R = 0. compute epsi = 1. loop. compute C = Kroneker(Ident(q),wp). compute wq = inv(t(C)*Phi*C)*t(C)*Psi. compute C = Kroneker(wq,Ident(p)). compute wp = inv(t(C)*Phi*C)*t(C)*Psi. compute epsi = t(Psi)*Kroneker(wq,wp) - R. compute R = R + epsi. end loop if (epsi lt 0.00001). compute MC_A = (Ca*wp/sqrt(t(Ca*wp)*Ca*wp)). compute MC_B = (Cb*wq/sqrt(t(Cb*wq)*Cb*wq)). do if (SWITCH eq 1 or SWITCH eq 2). print (Ca*wp/sqrt(t(Ca*wp)*Ca*wp))/title "A Contrast Coefficients: ". else. print (Ca*wp/sqrt(t(Ca*wp)*Ca*wp))/title "A Coefficients: ". end if. do if (SWITCH eq 1 or SWITCH eq 3). print (Cb*wq/sqrt(t(Cb*wq)*Cb*wq))/title "B Contrast Coefficients: ". else. print (Cb*wq/sqrt(t(Cb*wq)*Cb*wq))/title "B Coefficients". end if. print R/title "Maximal F ratio for Product Contrast". !enddefine. /*** Call ALSLOOP macro for Models 1, 2 and 3 as per Bird & HP (2005) /******************************************************************** define RUNALS(). matrix. get D/file=DESIGN. compute a = mmax(D(:,1)) - mmin(D(:,1)) + 1. compute b = mmax(D(:,2)) - mmin(D(:,2)) + 1. /* Cell means and their SE are stored in the EST and SE rows of the COVB matrix /* These rows follow the a x b covariance matrix. get X/file=COVB. compute Mu = t(X((a*b+1),5:(4+a*b))). compute Sigma = mdiag(t(X((a*b+2),5:(4+a*b)))&**2). print {Mu,Sqrt(Diag(Sigma))} /title " " /clabels " Means", " Std Errs". print/title="*** Calculations for AB (Model 1)"/space 2. compute SWITCH = 1. compute p = a - 1. compute q = b - 1. compute Ca = Ident(a,a-1) - make(a,a-1,1/a). compute Cb = Ident(b,b-1) - make(b,b-1,1/b). ALSLOOP. print/title="*** Calculations for A(B) (Model 2)"/space 2. compute SWITCH = 2. compute p = a - 1. compute q = b. compute Ca = Ident(a,a-1) - make(a,a-1,1/a). compute Cb = Ident(b,b). ALSLOOP. print/title="*** Calculations for B(A) (Model 3)"/space 2. compute SWITCH = 3. compute p = a. compute q = b - 1. compute Ca = Ident(a,a). compute Cb = Ident(b,b-1) - make(b,b-1,1/b). ALSLOOP. end matrix. !enddefine. * Main macro ************. define BOIK.MAC (!pos !tokens(1) / !pos !tokens(1) / !pos !tokens(1)). glm !1 by !2 !3 /intercept=exclude /print descriptives parameter /output = covb(COVB) design(DESIGN) /design = !2 by !3. RUNALS. !enddefine. BOIK.MAC Y A B.