# Counterbalancing for immediate sequential effects

**ALGORITHM (Williams)**

- Write down the N conditions in some order, say {1, 2, 3, ...} and its N-1 cyclic rotations
- Apply the interleaving permutation {1, 2, N, 3, N-1,4, N-2, ...} to each of these sequences
- If N is even, STOP, otherwise append the N sequences obtained by completely reversing the N sequences generated by steps 1 and 2.

**illustrated for N=6 (even)**

The interleaving permutation maps {1,2,3,4,5,6} to {1,2,6,3,5,4}.

Applying this to the columns of the cyclic matrix :

123456 234561 345612 456123 561234 612345

we get the sequentially counterbalanced 6x6 design:

126354 231465 342516 453621 564132 615243.

**Illustrated for N=7 (odd)**

The interleaving permutation maps {1,2,3,4,5,6,7} to {1,2,7,3,6,4,5}.

Applying this to the columns of the cyclic matrix :

1234567 2345671 3456712 4567123 5671234 6712345 7123456

we get the intermediate matrix:

1273645 2314756 3425167 4536271 5647312 6751423 7162534.

Appending the mirror image of the intermediate matrix we get the sequentially counterbalanced 14x7 design:

1273645 2314756 3425167 4536271 5647312 6751423 7162534 5463721 6574132 7615243 1726354 2137465 3241576 4352617.

**Here is some MATLAB code to perform this:**

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

**BIBLIOGRAPHY**

Archdeacon, D.S., Dinitz, J.H., and Stinson, D.R. (1980). Some new rowcomplete Latin Squares. Journal of Combinatorial Theory, Ser. A, 29, 395-- 398.

Mausumi Bose (Applied Statistics Unit, Indian Statistical Institute Kolkata, India) Crossover Designs: Analysis and Optimality Using the Calculus for Factorial Arrangements, Design Workshop Lecture Notes ISI, Kolkata, 25-29 November 2002, 83-192.

Bradley, J. V. (1958). Complete counterbalancing of immediate sequential effects in a Latin square design, Journal of the American Statistical Association, 53, 525-528.

Durso, F. T. (1984). A Subroutine for counterbalanced assignment of stimuli to conditions. Behaviour Research Methods, Instruments & Computers, 16(5), 471-472

Federer, Walter T. and Nguyen, Nam-Ky. Incomplete block designs. Volume 2, pp 1039–1042 in Encyclopedia of Environmetrics (ISBN 0471 899976) Edited by Abdel H. El-Shaarawi and Walter W. Piegorsch . John Wiley & Sons, Ltd, Chichester, 2002.

Lewis, J. R. (1993). Pairs of Latin squares that produce digram-balanced Greco-Latin designs: A BASIC program. Behaviour Research Methods, Instrument, & Computers, 25(3), 414-415

Ollis, Matt: Terraces and the Oberwolfach Problem

Prescott, P. (1999). Construction of sequentially counterbalanced designs formed from two Latin squares. Utilitas Mathematica, 55, 135-52.

Prescott, P. (1999). Construction of uniform-balanced cross-over designs for any odd number of treatments. Statistics in Medicine, 18, 265-72.

Williams, E. J. (1949). Experimental designs balanced for the estimation of residual effects of treatments. Australian Journal of Scientific Research, 2, 149-168.

[Last updated on 27 November, 2003]

Return to Statistics main page

These pages are maintained by Ian Nimmo-Smith and Peter Watson