Learn R Programming

PropScrRand (version 1.1.1)

genPerms: Generate Treatment Permutations

Description

Used within calls to pcr to generate a set of unique treatment permutations for randomization.

Usage

genPerms(n, n1, nPerms)

Arguments

n

Total number of units to be randomized.

n1

Number of units to receive treatment.

nPerms

Number of permutations to generate.

Value

The result is an n1 x nPerms (or n1 x choose(n, n1) or n1 x 2*nPerms) matrix. Each column represents one treatment permutation, with the values in the column giving the index of the treated units.

Details

This function randomly samples nPerms of the choose(n, n1) possible treatment permutations. If nPerms > choose(n, n1), then all choose(n, n1) permutations are generated systematically. Also, in the case of 1-to-1 allocation, the complement treatment vectors are also produced, so the returned matrix has 2*nPerms permutations. Uniqueness is checked throughout and duplicate permutations disgarded.

Examples

Run this code
# NOT RUN {
genPerms(n=50, n1=25, nPerms=500)
genPerms(n=50, n1=35, nPerms=500)
# }

Run the code above in your browser using DataLab