randomizeBE (version 0.3-5)

RL4: (Block) randomization of subjects, patients into sequence groups

Description

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.

Usage

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

Value

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

rl

A data.frame with the random list.

seed

The used seed.

blocksize

The used blocksize.

ninseqs

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

runs.pvalue

The p-value of a runs test of randomness.

date

Date and time of creation.


The class rl4 has the S3 method print.rl4.

Arguments

nsubj

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

seqs

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").

blocksize

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.

seed

An integer for the initialisation of the random number generator.

randctrl

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

pmethod

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".

alpha

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

Author

D. Labes
Part of the code for using the runs test for randomness according to a suggestion by Helmut Schuetz.

Details

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.

See Also

print.rl4, runs.pvalue

Examples

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

# 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"))
print(rl)

# 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

Run the code above in your browser using DataCamp Workspace