preserve. set printback=on. * SIMPLE AND COMPLEX RANDOM ASSIGNMENT IN EXPERIMENTAL DESIGN (Version 2.0) Valentim R. Alferes, University of Coimbra (Portugal), 2013. * WITHIN-SUBJECTS DESIGNS. * Program: SC-nrT5P5.sps Method 16: Nonrestricted Sequential Counterbalancing Complete Sequences (p = t): Special Sets of Sequences - Design 6F5: Mutually Orthogonal Latin Squares Design (t=5, n=20, p=5) - Design 6H5: Williams's Design / Double Carryover Design (t=5, n=10, p=5) - Design 6J5: Newcombe's and Prescoott's "Triples" Design (t=5, n=15, p=5) - Design 6L5: Russell's Design (t=5, n=5, p=5). * NOTE: Design 6H5 (one replication) is the minimal balanced design for the first order carryover effects. set printback=off. set ovars labels onumbers values tvars labels tnumbers labels. set olang=English small=0 errors=none decimal=dot. data list free/Design(f8.0). /* User's Specifications /* * Choose standard design: * 1 (for Design 6F5) * 2 (for Design 6H5) * 3 (for Design 6J5) * 4 (for Design 6L5). begin data 2 end data. * Enter number of replications of the standard design. compute nr=2. execute. save outfile='%temp%\fout0'. new file. data list free/design(f8.0) nsd(f8.0) nbricks(f8.0) permutn(f8.0). begin data 1 20 4 5 2 10 2 5 3 15 3 5 4 5 1 5 end data. save outfile='%temp%\fout1'. new file. data list free/design(f8.0) Brick(f8.0) Row(f8.0) P1(f8.0) P2(f8.0) P3(f8.0) P4(f8.0) P5(f8.0). begin data 1 1 1 1 2 3 4 5 1 1 2 2 3 4 5 1 1 1 3 3 4 5 1 2 1 1 4 4 5 1 2 3 1 1 5 5 1 2 3 4 1 2 1 1 3 5 2 4 1 2 2 2 4 1 3 5 1 2 3 3 5 2 4 1 1 2 4 4 1 3 5 2 1 2 5 5 2 4 1 3 1 3 1 1 4 2 5 3 1 3 2 2 5 3 1 4 1 3 3 3 1 4 2 5 1 3 4 4 2 5 3 1 1 3 5 5 3 1 4 2 1 4 1 1 5 4 3 2 1 4 2 2 1 5 4 3 1 4 3 3 2 1 5 4 1 4 4 4 3 2 1 5 1 4 5 5 4 3 2 1 2 1 1 1 2 3 4 5 2 1 2 2 4 1 5 3 2 1 3 3 1 5 2 4 2 1 4 4 5 2 3 1 2 1 5 5 3 4 1 2 2 2 1 1 3 2 5 4 2 2 2 2 1 4 3 5 2 2 3 3 5 1 4 2 2 2 4 4 2 5 1 3 2 2 5 5 4 3 2 1 3 1 1 1 2 3 4 5 3 1 2 2 4 5 3 1 3 1 3 3 5 2 1 4 3 1 4 4 3 1 5 2 3 1 5 5 1 4 2 3 3 2 1 1 4 3 2 5 3 2 2 2 3 5 4 1 3 2 3 3 1 2 5 4 3 2 4 4 5 1 3 2 3 2 5 5 2 4 1 3 3 3 1 1 5 3 2 4 3 3 2 2 1 5 4 3 3 3 3 3 4 2 5 1 3 3 4 4 2 1 3 5 3 3 5 5 3 4 1 2 4 1 1 1 2 3 4 5 4 1 2 2 4 5 3 1 4 1 3 3 5 2 1 4 4 1 4 4 3 1 5 2 4 1 5 5 1 4 2 3 end data. save outfile='%temp%\fout2'. get file='%temp%\fout0'. match files/file=*/table='%temp%\fout1'/by design. execute. loop x=1 to permutn. xsave outfile='%temp%\fout3'. end loop. get file='%temp%\fout3'. set rng=mt mtindex=random. compute rn=rv.uniform(0,1). execute. rank variables=rn(a)/rank/print=no/ties=condense. compute Permutation=rrn. execute. save outfile='%temp%\fout4'. loop permall=1 to nbricks. xsave outfile='%temp%\fout5'. end loop. get file='%temp%\fout5'. sort cases by permall(a) x(a). save outfile='%temp%\fout6'/keep permutation. get file='%temp%\fout4'. compute y=permutation. compute ntot=nsd*nr. execute. formats all(f8.0). value labels design 1'6F5' 2'6H5' 3'6J5' 4'6L5'. variable labels nsd"Number of Units in the Standard Design" ntot"Number "+ "of Units in the Final Design" nr"Number of Replications of the Standard Design". oms/select tables/if commands=["summarize"] subtypes=["case processing summary"]/destination viewer=no. summarize/tables=design nsd nr ntot/format=list nocasenum nototal limit=1 /title="User's Specifications"/cells=none. save outfile='%temp%\fout4'. get file='%temp%\fout2'. match files/file=*/table='%temp%\fout0'/by design. execute. sel if(nr>0). execute. value labels p1 to p5 1'A' 2'B' 3'C' 4'D' 5'E'. summarize/tables=brick row p1 to p5/format=list nocasenum nototal /title="Standard Design"/cells=none/footnote'P = Period'. save outfile='%temp%\fout2'. get file='%temp%\fout4'. value labels x y 1'A' 2'B' 3'C' 4'D' 5'E'. variable labels x"Symbols in the Standard Design" y"Symbols in the Randomly Selected Sequences". formats permutation(f8.0). summarize/tables=x permutation y/format=validlist nocasenum nototal /title='Random Permutation for the Symbols of the Standard Design'/cells=none. get file='%temp%\fout2'. sort cases by brick(a) p1(a). match files /file=*/file='%temp%\fout6'. execute. compute P_1=permutation. execute. delete variables permutation. sort cases by brick(a) p2(a). match files/file=*/file='%temp%\fout6'. execute. compute P_2=permutation. execute. delete variables permutation. sort cases by brick(a) p3(a). match files/file=*/file='%temp%\fout6'. execute. compute P_3=permutation. execute. delete variables permutation. sort cases by brick(a) p4(a). match files/file=*/file='%temp%\fout6'. execute. compute P_4=permutation. execute. delete variables permutation. sort cases by brick(a) p5(a). match files/file=*/file='%temp%\fout6'. execute. compute P_5=permutation. execute. delete variables permutation. sort cases by brick(a) p1(a). value labels p_1 to p_5 1'A' 2'B' 3'C' 4'D' 5'E'. summarize/tables=brick row p_1 to p_5/format=list nocasenum nototal/title="Randomly Selected Sequences"/cells=none /footnote'P = Period'. loop Replication=1 to nr. xsave outfile='%temp%\fout7'. end loop. get file='%temp%\fout7'. set rng=mt mtindex=random. compute rn=rv.uniform(0,1). execute. rank variables=rn(a)/rank/print=no/ties=condense. compute Unit=rrn. execute. formats all(f8.0). sort cases by replication(a) brick(a) row(a). summarize/tables=replication brick row unit p_1 to p_5/format=list nocasenum nototal/title='Method 16: Nonrestricted Sequential '+ 'Counterbalancing \n Final Randomization Sorted by Replication/Brick/Row' /cells=none/footnote 'P = Period'. sort cases by unit(a). summarize/tables=replication brick row unit p_1 to p_5/format=list nocasenum nototal/title='Method 16: Nonrestricted Sequential '+ 'Counterbalancing \n Final Randomization Sorted by Unit'/cells=none /footnote 'P = Period'. sort cases by p_1(a) p_2(a) p_3(a) p_4(a) unit(a). summarize/tables=replication brick row unit p_1 to p_5/format=list nocasenum nototal/title='Method 16: Nonrestricted Sequential '+ 'Counterbalancing \n Final Randomization Sorted by Sequence/Unit' /cells=none/footnote 'P = Period'. save outfile='%userprofile%\desktop\FinalDesign.sav'/keep replication brick row unit p_1 to p_5. get file='%userprofile%\desktop\FinalDesign.sav'. erase file='%temp%\fout0'. erase file='%temp%\fout1'. erase file='%temp%\fout2'. erase file='%temp%\fout3'. erase file='%temp%\fout4'. erase file='%temp%\fout5'. erase file='%temp%\fout6'. erase file='%temp%\fout7'. restore.