RL4 {randomizeBE} | R Documentation |
(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)
Arguments
nsubj |
Number of subjects, patients ... to be randomized. |
seqs |
Character representation of the sequences. |
blocksize |
Size of the blocks to randomize within. |
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? |
pmethod |
A character string describing the method for the p-value calculation of the runs
test. |
alpha |
Critical alpha value for re-creation of the randomlist based on the runs test. |
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 https://de.wikipedia.org/wiki/Run-Test for this.
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
.
Note
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 ...
Author(s)
D. Labes
Part of the code for using the runs test for randomness
according to a suggestion by Helmut Schuetz.
See Also
Examples
# 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