Enumerate or sample permutations of treatment assignments in a one-way design.
1 2 3 4 5
A vector of treatment labels
A positive integer of the number of permutations requested.
A logical scalar, indicating whether only factoradic indices are computed. This has no effect when
The sample size in each treatment group.
nparts functions computes the total number of partitions, with sizes being specified by
Denote the totality by
B is no smaller than
nparts(table(trt)), all partitions are returned by
B is set to
Otherwise, a sample
B random permutations will be selection from a total of
N! possible permutations (without replacement).
permuteTrt, it returns S3 object of class
'permutedTrt', which is a list
length(unique(trt)) treatment assignment matrices. When
FALSE, each matrix has
B columns, where
B may be smaller than requested, such that
ANS[[i]][,b] contains sorted individual indices that are allocated to treatment
i under the
bth random permutation. Note that, here
b should not be interpreted as the factoradic number. That is, the column locations of the matrices have no special meaning. However, an exception is that the first column (i.e., the first permutation) is always equivalent to the original treatment assignment. In other words, it is guaranteed that
setequal( split(seq(length(trt)),trt), lapply(ANS, '[', , 1L)) should always be
TRUE. In addition, the
'idx' attribute of the result is set to
TRUE, each matrix has only one column, corresponding to the original treatment assignment. The permutations being sampled represented by the correspoding decimal factoradic numbers (stored as character) returned in the
'idx' attribute. In this case, the length of the
'idx' attribute is
B and the first element is always
"0", corresponding to no permutations.
nparts returns the total number of non-equivalent treatment assignments.
nperms.permutedTrt returns the total number of permutations.
ntrt.permutedTrt returns a named vector of sample sizes.
trt.permutedTrt recovers the
trt vector passed to
B is less than
nparts(table(trt)), ideally one could randomly sample
B partitions from a total of
nparts(table(trt)) without replacement, subject to the first partition being equivalent to the original treatment assignment. For the sake of simplicity, this is not implemented here. The random sample of size
B is generated from a total of
N! permutations without replacement. Therefore, it is possible for some of the permutations sampled corresponding to equivalent partitions. However, for the purpose of permutation tests, the type I error rate is still under control.
1 2 3 4 5 6 7 8 9
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.