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.
Usage
## S3 method for class 'xbal'
plot(x, xlab = "Standardized Differences",
statistic = "std.diff", absolute = FALSE, strata.labels = NULL,
variable.labels = NULL, groups = NULL, ...)
Arguments
x
An object returned by xBalance
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 c(strata1 = "Strata Label 1", ...)
that maps the stratification schemes to textual labels.
variable.labels
A named vector of the from c(var1 = "Var Label1", ...)
that maps the variables to textual labels.
groups
A vector of group names for each variable in
x$results. By default, factor level variables will be
grouped.
...
additional arguments to pass to balanceplot
Details
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.
See Also
xBalance, subset.xbal, balanceplot
Examples
data(nuclearplants)
xb <- xBalance(pr ~ date + t1 + t2 + cap + ne + ct + bw + cum.n,
data = nuclearplants,
strata = list("none" = NULL,
"pt" = ~pt))
# 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("none" = "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("none" = "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"))
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(RItools)
Loading required package: SparseM
Attaching package: 'SparseM'
The following object is masked from 'package:base':
backsolve
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RItools/plot.xbal.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot.xbal
> ### Title: Plot of balance across multiple strata
> ### Aliases: plot.xbal
>
> ### ** Examples
>
> data(nuclearplants)
>
> xb <- xBalance(pr ~ date + t1 + t2 + cap + ne + ct + bw + cum.n,
+ data = nuclearplants,
+ strata = list("none" = NULL,
+ "pt" = ~pt))
>
> # 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("none" = "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("none" = "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"))
>
>
>
>
>
> dev.off()
null device
1
>