View source: R/permTest.absBias.R
permTest.absBias | R Documentation |
permTest.absBias
performs a permutation test for complete randomization using the sum of absolute biases as a test statistic.
permTest.absBias(X, D = NULL, Z = NULL,
assignment = "complete",
perms = 1000, subclass = NULL)
X |
Covariate matrix (with units as rows and covariates as columns). |
D |
Indicator vector for a binary treatment (must contain 1 or 0 for each unit). |
Z |
Indicator vector for a binary instrument (must contain 1 or 0 for each unit). |
assignment |
Must be "complete", "block", or "bernoulli". Designates whether to test for complete randomization, block randomization, or Bernoulli trials. |
subclass |
Vector of subclasses (one for each unit). Subclasses can be numbers or characters, as long as there is one specified for each unit. Only needed if |
perms |
Number of permutations used to approximate the permutation test. |
p-value testing whether or not an indicator (treatment or instrument) is as-if randomized under complete randomization (i.e., random permutations), block randomization (i.e., random permutations within subclasses), or Bernoulli trials.
Zach Branson and Luke Keele
Branson, Z. and Keele, L. (2020). Evaluating a Key Instrumental Variable Assumption Using Randomization Tests. American Journal of Epidemiology. To appear.
#load the data
data(icu.data)
#the covariate matrix is
X = as.matrix(subset(icu.data, select = -c(open_bin, icu_bed)))
#the treatment
D = icu.data$icu_bed
#the instrument
Z = icu.data$open_bin
#the subclass
subclass = icu.data$site
#can uncomment the following code for examples
#permutation test for complete randomization (for the treatment)
#permTest.absBias(X = X, D = D,
#assignment = "complete", perms = 500)
#permutation test for complete randomization (for the instrument)
#permTest.absBias(X = X, D = D, Z = Z,
#assignment = "complete", perms = 500)
#permutation test for block randomization (for the treatment)
#permTest.absBias(X = X, D = D,
#assignment = "block", subclass = subclass, perms = 500)
#permutation test for block randomization (for the instrument)
#permTest.absBias(X = X, D = D, Z = Z,
#assignment = "block",
#subclass = subclass, perms = 500)
#permutation test for bernoulli trials (for the treatment)
#permTest.absBias(X = X, D = D,
#assignment = "bernoulli", perms = 500)
#permutation test for bernoulli randomization (for the instrument)
#permTest.absBias(X = X, D = D, Z = Z,
#assignment = "bernoulli", perms = 500)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.