<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>FAQ/CounterBalancing</title><revhistory><revision><revnumber>5</revnumber><date>2013-03-08 10:17:26</date><authorinitials>localhost</authorinitials><revremark>converted to 1.6 markup</revremark></revision><revision><revnumber>4</revnumber><date>2006-07-12 16:43:50</date><authorinitials>devel06.mrc-cbu.cam.ac.uk</authorinitials></revision><revision><revnumber>3</revnumber><date>2006-06-30 22:56:57</date><authorinitials>Scripting Subsystem</authorinitials></revision><revision><revnumber>2</revnumber><date>2006-06-30 22:55:26</date><authorinitials>Scripting Subsystem</authorinitials></revision><revision><revnumber>1</revnumber><date>2006-06-30 21:37:47</date><authorinitials>Scripting Subsystem</authorinitials></revision></revhistory></articleinfo><section><title>Counterbalancing for immediate sequential effects</title><para><emphasis role="strong">ALGORITHM (Williams)</emphasis> </para><orderedlist numeration="arabic"><listitem><para>Write down the N conditions in some order, say {1, 2, 3, ...} and its N-1 cyclic rotations </para></listitem><listitem><para>Apply the interleaving permutation {1, 2, N, 3, N-1,4, N-2, ...} to each of these sequences </para></listitem><listitem><para>If N is even, STOP, otherwise append the N sequences obtained by completely reversing the N sequences generated by steps 1 and 2. </para></listitem></orderedlist><para><emphasis><emphasis role="strong">illustrated for N=6 (even)</emphasis></emphasis> </para><para>The interleaving permutation maps {1,2,3,4,5,6} to {1,2,6,3,5,4}. </para><para>Applying this to the columns of the cyclic matrix : </para><itemizedlist><listitem override="none"><screen><![CDATA[123456
234561
345612
456123
561234
612345]]></screen></listitem></itemizedlist><para>we get the sequentially counterbalanced 6x6 design: </para><itemizedlist><listitem override="none"><screen><![CDATA[126354
231465
342516
453621
564132
615243.]]></screen></listitem></itemizedlist><para><emphasis><emphasis role="strong">Illustrated for N=7 (odd)</emphasis></emphasis> </para><para>The interleaving permutation maps {1,2,3,4,5,6,7} to {1,2,7,3,6,4,5}. </para><para>Applying this to the columns of the cyclic matrix : </para><itemizedlist><listitem override="none"><screen><![CDATA[1234567
2345671
3456712
4567123
5671234
6712345
7123456]]></screen></listitem></itemizedlist><para>we get the intermediate matrix: </para><itemizedlist><listitem override="none"><screen><![CDATA[1273645
2314756
3425167
4536271
5647312
6751423
7162534.]]></screen></listitem></itemizedlist><para>Appending the mirror image of the intermediate matrix we get the sequentially counterbalanced 14x7 design: </para><itemizedlist><listitem override="none"><screen><![CDATA[1273645
2314756
3425167
4536271
5647312
6751423
7162534
5463721
6574132
7615243
1726354
2137465
3241576
4352617.]]></screen></listitem></itemizedlist><para><emphasis role="strong">Here is some MATLAB code to perform this:</emphasis> </para><itemizedlist><listitem override="none"><screen><![CDATA[function design = williams(n)
% Ian Nimmo-Smith (MRC CBU) April 2003
cyclic = toeplitz([1,(n:(-1):2)],[1:n]);
cyclic = cyclic([1,(n:(-1):2)],:);
baseperm = [1];
half = floor(n/2);
if n == 2*half    % even
    for j = 1:(half-1)
        baseperm = [baseperm, j+1, n-j+1];
    end
    baseperm = [baseperm, half+1];
else              % odd
    for j = 1:half
        baseperm = [baseperm, j+1, n-j+1];
    end
end
design = cyclic(:,baseperm);
if n ~= 2*half
    design = [design;design(:,(n:(-1):1))];
end      ]]></screen></listitem></itemizedlist><para><emphasis role="strong">BIBLIOGRAPHY</emphasis> </para><para>Archdeacon, D.S., Dinitz, J.H., and Stinson, D.R. (1980). Some new row­complete Latin Squares. Journal of Combinatorial Theory, Ser. A, 29, 395-- 398. </para><para>Mausumi Bose (Applied Statistics Unit, Indian Statistical Institute Kolkata, India) <ulink url="http://www.isid.ac.in/~ashish/workshop/mausumiw3.pdf">Crossover Designs: Analysis and Optimality Using the Calculus for Factorial Arrangements</ulink>, Design Workshop Lecture Notes ISI, Kolkata, 25-29 November 2002, 83-192. </para><para>Bradley, J. V. (1958). Complete counterbalancing of immediate sequential effects in a Latin square design, Journal of the American Statistical Association, 53, 525-528. </para><para>Durso, F. T. (1984). A Subroutine for counterbalanced assignment of stimuli to conditions. Behaviour Research Methods, Instruments &amp; Computers, 16(5), 471-472 </para><para>Federer, Walter T. and Nguyen, Nam-Ky. <ulink url="http://designcomputing.net/gendex/pdf/federer.pdf">Incomplete block designs</ulink>. Volume 2, pp 1039–1042 in Encyclopedia of Environmetrics (ISBN 0471 899976) Edited by Abdel H. El-Shaarawi and Walter W. Piegorsch . John Wiley &amp; Sons, Ltd, Chichester, 2002. </para><para>Lewis, J. R. (1993). Pairs of Latin squares that produce digram-balanced Greco-Latin designs: A BASIC program. Behaviour Research Methods, Instrument, &amp; Computers, 25(3), 414-415 </para><para>Ollis, Matt: <ulink url="http://www.maths.qmul.ac.uk/postgraduate/anncook/ollis(ac).pdf">Terraces and the Oberwolfach Problem</ulink> </para><para>Prescott, P. (1999). Construction of sequentially counterbalanced designs formed from two Latin squares. Utilitas Mathematica, 55, 135-52. </para><para>Prescott, P. (1999). Construction of uniform-balanced cross-over designs for any odd number of treatments. Statistics in Medicine, 18, 265-72. </para><para>Williams, E. J. (1949). Experimental designs balanced for the estimation of residual effects of treatments. Australian Journal of Scientific Research, 2, 149-168. </para><para>[Last updated on 27 November, 2003] </para><!--rule (<hr>) is not applicable to DocBook--><para> <ulink url="https://lsr-wiki-02.mrc-cbu.cam.ac.uk/statswiki/FAQ/CounterBalancing/statswiki/FAQ#">Return to Statistics FAQ page</ulink> </para><para><ulink url="https://lsr-wiki-02.mrc-cbu.cam.ac.uk/statswiki/FAQ/CounterBalancing/statswiki/CbuStatistics#">Return to Statistics main page</ulink> </para><para><ulink url="http://www.mrc-cbu.cam.ac.uk/">Return to CBU main page</ulink> </para><para>These pages are maintained by <ulink url="mailto:ian.nimmo-smith@mrc-cbu.cam.ac.uk">Ian Nimmo-Smith</ulink> and <ulink url="mailto:peter.watson@mrc-cbu.cam.ac.uk">Peter Watson</ulink> </para></section></article>