plot.xbal | 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 'xbal'
plot(
x,
xlab = "Standardized Differences",
statistic = "std.diff",
absolute = FALSE,
strata.labels = NULL,
variable.labels = NULL,
groups = NULL,
ggplot = FALSE,
...
)
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
|
ggplot |
Use ggplot2 to create figure. By default, uses base R graphics. |
... |
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.
xBalance
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.
Returns NULL, displays plot
xBalance
, subset.xbal
, balanceplot
data(nuclearplants)
xb <- xBalance(pr ~ date + t1 + t2 + cap + ne + ct + bw + cum.n,
strata = list(none = NULL, pt = ~pt),
data = nuclearplants)
# Using the default grouping:
plot(xb, variable.labels = c(date = "Date",
t1 = "Time 1",
t2 = "Time 2",
cap = "Capacity",
ne = "In North East",
ct = "Cooling Tower",
bw = "Babcock-Wilcox",
cum.n = "Total Plants Built"),
strata.labels = c("--" = "Raw Data", "pt" = "Partial Turn-key"),
absolute = TRUE)
# Using user supplied grouping
plot(xb, variable.labels = c(date = "Date",
t1 = "Time 1",
t2 = "Time 2",
cap = "Capacity",
ne = "In North East",
ct = "Cooling Tower",
bw = "Babcock-Wilcox",
cum.n = "Total Plants Built"),
strata.labels = c("--" = "Raw Data", "pt" = "Partial Turn-key"),
absolute = TRUE,
groups = c("Group A", "Group A", "Group A", "Group B",
"Group B", "Group B", "Group A", "Group B"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.