balanceplot | R Documentation |
This plotting function summarizes variable by stratification matrices. For
each variable (a row in the x
argument), the values are under each
stratification (the columns of x
) plotted on the same line.
balanceplot(
x,
ordered = FALSE,
segments = TRUE,
colors = "black",
shapes = c(15, 16, 17, 18, 0, 1, 10, 12, 13, 14),
segments.args = list(col = "grey"),
points.args = list(cex = 1),
xlab = "Balance",
xrange = NULL,
groups = NULL,
tiptext = NULL,
include.legend = TRUE,
legend.title = NULL,
plotfun = .balanceplot,
...
)
x |
A matrix of variables (rows) by strata (columns). |
ordered |
Should the variables be ordered from most to least imbalance on the first statistic? |
segments |
Should lines be drawn between points for each variable? |
colors |
Either a vector or a matrix of shape indicators
suitable to use as a |
shapes |
Either a vector or a matrix of shape indicators
suitable to use as a |
segments.args |
A list of arguments to pass to the
|
points.args |
A list of arguments to pass to the |
xlab |
The label of the x-axis of the plot. |
xrange |
The range of x-axis. By default, it is 1.25 times the range of |
groups |
A factor that indicates the group of each row in
|
tiptext |
ignored (legacy argument retained for internal reasons)
<!– If you are using the |
include.legend |
Should a legend be included? |
legend.title |
An optional title to attach to the legend. |
plotfun |
Function to do the plotting; defaults to [RItools:::.balanceplot] |
... |
Additional arguments to pass to |
It is conventional to standardize the differences to common scale
(e.g. z-scores), but this is not required. When ordered
is
set to true, plotting will automatically order the data from
largest imbalance to smallest based on the first column of
x
.
You can fine tune the colors and shapes with the like named
arguments. Any other arguments to the points
function
can be passed in a list as points.args
. Likewise, you can
fine tune the segments between points with segments.args
.
Returns NULL, displays plot
plot.xbal
, xBalance
,
segments
, points
set.seed(20121204)
# generate some balance data
nvars <- 10
varnames <- paste("V", letters[1:nvars])
balance_data <- matrix(c(rnorm(n = nvars, mean = 1, sd = 0.5),
rnorm(n = nvars, mean = 0, sd = 0.5)),
ncol = 2)
colnames(balance_data) <- c("Before Adjustment", "After Matching")
rownames(balance_data) <- varnames
balanceplot(balance_data,
colors = c("red", "green"),
xlab = "Balance Before/After Matching")
# base R graphics are allowed
abline(v = colMeans(balance_data), lty = 3, col = "grey")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.