genperms: Generate flexible permutation matrix for blocked, clustered...

Description Usage Arguments Details Value References

View source: R/regression_functions.R

Description

An alternative version of ri::genperms. Given user-input vectors of clusters or blocks, generate an exact permutation matrix, or a randomly sampled permutation matrix if the number of actual permutations is too high. Improves upon ri::genperms by allowing permutation of non-binary vectors.

Usage

1
genperms(x, block = NULL, clus = NULL, maxiter = 10000)

Arguments

x

a vector to be permuted. Can be continuous

block

a vector of equal length as x, with unique values indicating different blocks

clus

a vector of equal length as x, with unique values indicating different blocks

maxiter

maximum number of permutations to be included in the permutation matrix. If it is possible to perform exact permutation with fewer permutations, then the exact permutation matrix is produced.

Details

Unlike its counterpart in the ri package, this function can perform permutation of input vectors that are not binary. It also accepts as arguments for blockvar and clustvar other data types than integer. genperms is primarily based on the permute package.

Value

A permutation matrix where each row is a permutation of the input vector x

References

Gerber, Alan S. and Donald P. Green. 2012. Field Experiments: Design, Analysis, and Interpretation. New York: W.W. Norton.


mdtrinh/vietnamdata documentation built on May 3, 2019, 11:49 p.m.