View source: R/plot.balancetest.R
plot.balancetest | R Documentation |
The plot allows a quick visual comparison of the effect of different
stratification designs on the comparability of different
variables. This is not a replacement for the omnibus statistical test
reported as part of print.xbal
. This plot does allow the
analyst an easy way to identify variables that might be the primary culprits
of overall imbalances and/or a way to assess whether certain important
covariates might be imbalanced even if the omnibus test reports that
the stratification overall produces balance.
## S3 method for class 'balancetest'
plot(
x,
xlab = "Standardized Differences",
statistic = "std.diff",
absolute = FALSE,
strata.labels = NULL,
variable.labels = NULL,
groups = NULL,
...
)
x |
An object returned by |
xlab |
The label for the x-axis of the plot |
statistic |
The statistic to plot. The default choice of standardized difference is a good choice as it will have roughly the same scale for all plotted variables. |
absolute |
Convert the results to the absolute value of the statistic. |
strata.labels |
A named vector of the from |
variable.labels |
A named vector of the from |
groups |
A vector of group names for each variable in
|
... |
additional arguments to pass to |
By default all variables and all strata are plotted. The scope
of the plot can be reduced by using the subset.xbal
function to
make a smaller xbal
object with only the desired variables or
strata.
balanceTest
can produce several different summary statistics for
each variable, any of which can serve as the data for this plot. By default,
the standardized differences between treated and control units makes a good
choice as all variables are on the same scale. Other statistics can be
selected using the statistic
argument.
The result of this function is a ggplot
object. Most display of
the plot can be manipulated using additional commands appended to the plot
option. For example, the entire theme of the plot can be changed to black and
white using plot(b) + theme_bw()
, where b
is the result of a
call to balanceTest
. The points on the plot are known as
"values", so colors or symbols used for each strata can be updated using the
scale_color_manual
function. For example, plot(b) +
scale_color_manaual(values = c('red', 'green', 'blue'))
for a balance test
of three stratification variables.
A ggplot2
object that can be further manipulated (e.g., to set the colors or text).
balanceTest
, ggplot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.