options ps=500 nodate; title ' '; PROC IML; /* This Program is for Selecting the Best Design Taking into Account the Interactions Between Lower and Higher Stratum Factors */ print 'INTERACTION PHASE OF MULTILEVEL STRUCTURE DESIGN'; start DESIGN; TRIES=10; /* Enter Number of Tries */ BLOCK=6; /* Enter Total Number of Blocks */ NF1=1; /* Enter the Number of Factors in the Previous Level*/ BSIZE={3,3,3,3,3,3}; /* Enter Vector of Block Sizes */ /* Enter Presence (1)/ Absence (0) */ /* of Terms in the Model - Based on */ /* the Full Second-order Model */ /* Main Effects of the Higher Stratum Factors should not be in the Model */ MODEL={0 1 1 0 1 1 1 1 1}; /* Enter Weights for each Interaction. */ WEI={1 1 1}; /* Enter the Treatment Set */ /* XX is the treatment set Matrix */ XX={ 0 0 0 1, 0 0 1 0, -1 0 0 0, 0 0 0 0, 0 1 0 0, 0 0 0 0, -1 1 -1 1, 1 1 1 -1, 1 -1 -1 -1, -1 -1 1 1, 0 0 0 0, 1 1 1 1, -1 1 -1 -1, -1 -1 1 -1, 1 -1 -1 1, 0 0 -1 0, 1 0 0 0, 0 0 0 -1, 0 -1 0 0, 0 0 0 0, 0 0 0 0, 1 1 -1 1, 1 -1 1 -1, -1 1 1 -1, -1 -1 -1 1, 1 -1 1 1, 0 0 0 0, 1 1 -1 -1, -1 1 1 1, -1 -1 -1 -1}; XN=XX; /* B is the design matrix for blocks */ B=i(BLOCK)@j(BSIZE,1,1); finish; start SWAP; BET=0; do J=1 to BLOCK; AB=0; R1=(J-1)*BSIZE; do I=1 to BLOCK; if AB>0 | I>J then do; DIF=0; R2=(I-1)*BSIZE; if any(XN[R1+1:R1+BSIZE,1:NF1]^=XN[R2+1:R2+BSIZE,1:NF1]) then do; XI=XN; XI[R1+1:R1+BSIZE,NF1+1:KFAC]=XN[R2+1:R2+BSIZE,NF1+1:KFAC]; XI[R2+1:R2+BSIZE,NF1+1:KFAC]=XN[R1+1:R1+BSIZE,NF1+1:KFAC]; run MODEL(XI); IT=XM`*PP*XM; if det(IT)^=0 then do; VNC=inv(IT); VNC=vecdiag(VNC); CRIN=WEI*VNC/sum(WEI); if CRIN0); run GENERATE; end; XINVU=inv(IT); VARF=vecdiag(XINVU); CRITERI=WEI*VARF/sum(WEI); BET=1; do until(BET=0); run SWAP; end; if CRITERI