(Block) randomization of subjects, patients into sequence groups

This function creates a randomization list of subjects, patients into sequences of treatments. It is mainly intended for use in crossover studies but may be used also for parallel group designs if for sequences c("T","R") is used.

RL4(nsubj, seqs = c("TR", "RT"), blocksize, seed=runif(1,max=1E7), 
    randctrl=TRUE, pmethod=c("normal", "exact", "cc"), alpha=0.025)

Number of subjects, patients ... to be randomized. Or a vector of the subject numbers (f.i. 1001:1012)


Character representation of the sequences. In BE studies for a 2x2 cross-over usually something like c("TR", "RT"). If you prefer the ABC notation write down here f.i. c("AB", "BA").


Size of the blocks to randomize within. If blocksize is missing it defaults to 2*number of sequences. blocksize may be a vector of numbers. In that case the sizes of the blocks are randomly chosen from that vector. If blocksize=0 then the randomization takes place in the one block with all subjects.


An integer for the initialisation of the random number generator.


Shall the creation of the randomlist controlled by a runs test of randomness? Defaults to TRUE.


A character string describing the method for the p-value calculation of the runs test. "normal" denotes the normal approximation like the function(s) runs.test() of the packages tseries or lawstat. "exact" chooses the calculation via exact distribution of the # of runs. "cc" chooses the continuity correction to the large sample approximation like in the statistical software SPSS. Default is pmethod="normal".


Critical alpha value for re-creation of the randomlist based on the runs test. Recommended is alpha=0.025.


As default the randomization is done as block randomization. If blocksize is given as a vector of numbers the sizes of the blocks are randomly chosen from that vector. If blocksize=0 then the randomization takes place in the one block with all subjects. The randomization is in the default settings controlled by a Wald-Wolfowitz runs test of randomness, i.e. if this test shows significant deviation from randomness (p-value<0.025 as default) the randomization list is recreated. This behavior may be switched off by setting randctrl=FALSE if you don't see any needfulness for such a control. The reason for such a control was originally to avoid randomlists with only 'alternating' sequences f.i. "TR" "RT" "TR" "RT" ... See http://forum.bebac.at/mix_entry.php?id=8745 In its original form the runs test is only defined for dichotomous outcomes (i.e if 2 sequences are used). If more than 2 sequences are used the runs test is modified by dichotomizing the sample of sequence numbers into cases < median and > median. See package lawstat or http://de.wikipedia.org/wiki/Run-Test for this.


Returns a list of class "rl4". This list has the components


A data.frame with the random list.


The used seed.


The used blocksize.


A named vector containing the number of subjects in the sequence groups.


The p-value of a runs test of randomness.


Date and time of creation.

The class rl4 has the S3 method print.rl4.


The blocksize(s) should be a multiple of the used # of sequences. If this is not the case it (they) will be adjusted accordingly. The number of subjects should be a multiple of the used # of sequences. If this is not the case a warning is thrown that the design is not balanced. The default for pmethod is the calculation via standard normal approximation. This has shown the 'best' potential in rejecting the randomness for alternating random lists. The randomness control does not work properly if more than 2 sequences are used. In that case a test of repeated patterns of sequences in blocks of length=nseq is done additionally to the runs test. Example (seqno) 1 2 3 1 2 3 ...

See Also

print.rl4, runs.pvalue

  • RL4
# block randomization of 12 subjects for a 2x2 cross-over using the defaults
# seqs = c("TR", "RT"), blocksize=4 and seed from Sys.time()

# block randomization of a full replicate design with randomly
# chosen blocksizes 2 or 4
rl <- RL4(nsubj=12, blocksize=c(2, 4), seqs=c("TRRT","RTTR"))

# randomization of 12 subjects for a 2x2 cross-over
# where the original random list don't pass the runs test
# watch the message.
RL4(nsubj=12, blocksize=0, seed=10)
#if you don't worry about some 'extreme' lists
RL4(nsubj=12, blocksize=0, seed=10, randctrl=FALSE)

# randomness control does'nt work that good in case of more 
# than 2 sequences: 3x3 latin square example
rl <- RL4(nsubj=12, seq <- c("ABC","BCA","CAB"), blocksize=3, seed=5125)
print(rl, sumry=TRUE)
# gives runs p.value=0.2502
# }
Documentation reproduced from package randomizeBE, version 0.3-5, License: GPL (>= 2.0)

Community examples

Looks like there are no examples yet.