preserve. set printback=on. * SIMPLE AND COMPLEX RANDOM ASSIGNMENT IN EXPERIMENTAL DESIGN (Version 2.0) Valentim R. Alferes, University of Coimbra (Portugal), 2014. * WITHIN-SUBJECTS DESIGNS. * Program: PC-Ls2345.sps Method 15: Positional Counterbalancing - Design 6M2: Repeated Measures Latin Square Design (t=2, n=2, p=2) - Design 6M3: Repeated Measures Latin Square Design (t=3, n=3, p=3) - Design 6M4: Repeated Measures Latin Square Design (t=4, n=4, p=4) - Design 6M5: Repeated Measures Latin Square Design (t=5, n=5, p=5) set printback=off. set ovars labels onumbers values tvars labels tnumbers labels. set olang=English small=0 errors=none decimal=dot. /* User Specifications /* * Enter the order (number of treatments) of the Latin square (2, 3, 4, or 5). data list free/Order(f8.0). begin data 5 end data. set rng=mt mtindex=random. if (order=2) rn=1. if (order=3) rn=1. if (order=4) rn=rnd(rv.uniform(.5,4.5)). if (order=5) rn=rnd(rv.uniform(.5,56.5)). execute. save outfile='%temp%\fout0'. new file. data list free/Order(f8.0) Square(f8.0) Row(f8.0) Column_1(f8.0) Column_2(f8.0) Column_3(f8.0) Column_4(f8.0) Column_5(f8.0). begin data 2 1 1 1 2 0 0 0 2 1 2 2 1 0 0 0 3 1 1 1 2 3 0 0 3 1 2 2 3 1 0 0 3 1 3 3 1 2 0 0 4 1 1 1 2 3 4 0 4 1 2 2 1 4 3 0 4 1 3 3 4 1 2 0 4 1 4 4 3 2 1 0 4 2 1 1 2 3 4 0 4 2 2 2 1 4 3 0 4 2 3 3 4 2 1 0 4 2 4 4 3 1 2 0 4 3 1 1 2 3 4 0 4 3 2 2 3 4 1 0 4 3 3 3 4 1 2 0 4 3 4 4 1 2 3 0 4 4 1 1 2 3 4 0 4 4 2 2 4 1 3 0 4 4 3 3 1 4 2 0 4 4 4 4 3 2 1 0 5 1 1 1 2 3 4 5 5 1 2 2 1 4 5 3 5 1 3 3 4 5 2 1 5 1 4 4 5 1 3 2 5 1 5 5 3 2 1 4 5 2 1 1 2 3 4 5 5 2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 3 3 4 2 5 1 5 53 4 4 3 5 1 2 5 53 5 5 1 4 2 3 5 54 1 1 2 3 4 5 5 54 2 2 5 1 3 4 5 54 3 3 4 5 1 2 5 54 4 4 3 2 5 1 5 54 5 5 1 4 2 3 5 55 1 1 2 3 4 5 5 55 2 2 5 4 1 3 5 55 3 3 4 1 5 2 5 55 4 4 3 5 2 1 5 55 5 5 1 2 3 4 5 56 1 1 2 3 4 5 5 56 2 2 5 4 1 3 5 56 3 3 4 5 2 1 5 56 4 4 3 1 5 2 5 56 5 5 1 2 3 4 end data. match files/file=*/table='%temp%\fout0'/by order. execute. sel if(rn=square). execute. delete variables rn. set results=no. flip variables=all. set results=yes. sel if(var001<>0). execute. set results=no. flip variables=all/newname=case_lbl. set results=yes. delete variables case_lbl. value labels all 1'A' 2'B' 3'C' 4'D' 5'E'. value labels order square row -1'x'. oms/select tables/if commands=["summarize"] subtypes=["case processing summary"]/destination viewer=no. formats all(f8.0). summarize/tables=all/format=list nocasenum nototal /cells=none /title='Square 1: Selected Standard Latin Square'/footnote 'Order 2: There is only one standard Latin square\nOrder 3: There is '+ 'only one standard Latin square\nOrder 4: Random selection of one of '+ 'the 4 standard Latin squares\nOrder 5: Random selection of one of the '+ '56 standard Latin squares'. delete variables order square row. set results=no. flip variables=all. set results=yes. set rng=mt mtindex=random. compute rn=rv.uniform(0,1). execute. compute permcols=$casenum. execute. sort cases by rn(a). variable labels permcols'Permutation'. formats permcols(f8.0). summarize/tables=permcols/format=list nocasenum nototal /title='Random Permutation for the Columns of Square 1'/cells=none. delete variables rn permcols. set results=no. flip variables=all/newname=case_lbl. set results=yes. delete variables case_lbl. compute Row=$casenum. execute. value labels all 1'A' 2'B' 3'C' 4'D' 5'E'. value labels row -1'x'. formats all(f8.0). summarize/tables=row all/format=list nocasenum nototal /title='Square 2: Random Permutation of Square 1 Columns'/cells=none. compute rn=rv.uniform(0,1). execute. if($casenum=1) rn=0. execute. sort cases by rn(a). compute permrows=row. execute. variable labels permrows'Permutation'. value labels permrows 1'Fixed in 1st place'. formats all(f8.0). summarize/tables=permrows/format=list nocasenum nototal /title='Random Permutation for the n-1 Last Rows of Square 2'/cells=none. delete variables rn permrows. formats all(f8.0). summarize/tables=row all/format=list nocasenum nototal /title='Square 3: Random Permutation of Square 2 Rows'/cells=none. delete variables row. set results=no. flip variables=all. set results=yes. compute myname=$casenum. execute. string yourname(a8). compute yourname='P_'. execute. string finalname(A8). compute finalname=concat(rtrim(yourname),ltrim(string(myname,f5))). execute. delete variables case_lbl myname yourname. set results=no. flip all/newname=finalname. set results=yes. delete variables case_lbl. value labels all 1'A' 2'B' 3'C' 4'D' 5'E'. compute Unit=$casenum. execute. formats all(f8.0). summarize/tables=unit all/format=list nocasenum nototal /title='Final Randomization (Square 3)' /footnote 'P = Period. \n'+ 'If necessary, repeat the syntax for each new set of n units.'/cells=none. save outfile='%userprofile%\desktop\FinalRandomization.sav'/keep unit all. get file='%userprofile%\desktop\FinalRandomization.sav'. erase file='%temp%\fout0'. restore.