View source: R/distributionBalancePlot.R
distributionBalancePlot | R Documentation |
distributionBalancePlot
displays the randomization distribution of the square root of the Mahalanobis distance across the treatment and/or instrument for different assignment mechanisms. This function supports complete randomization (displayed in black), block randomization (displayed in green), and Bernoulli trials for exposure (displayed in red) and instrument (displayed in blue). This function is used to create Figure 4 of Branson and Keele (2020).
distributionBalancePlot(X, D = NULL, Z = NULL, subclass = NULL,
complete = FALSE, blocked = FALSE, bernoulli = FALSE, perms = 1000)
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). |
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 |
complete |
If |
blocked |
If |
bernoulli |
If |
perms |
Number of permutations used to approximate the randomization distributions. |
Plot of randomization distributions of the square root of the Mahalanobis distance across the treatment and/or instrument for different assignment mechanisms.
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
#make distribution plot of sqrt(MD) for
#complete randomization, block randomization, and bernoulli trials
#(just uncomment the code below)
#distributionBalancePlot(X = X, D = D, Z = Z, subclass = subclass,
#complete = TRUE, blocked = TRUE, bernoulli = TRUE, perms = 500)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.