balanceplot: Create a plot of the balance on variables across different...

Description Usage Arguments Details See Also Examples

View source: R/plot.xbal.R View source: R/plot.xbal.R

Description

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.

Usage

1
2
3
4
5
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, ...)

Arguments

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 col argument to the points function. If the argument is a vector, the length should be the same as the number of columns in x. If the argument is a matrix, it should have the same dims as x.

shapes

Either a vector or a matrix of shape indicators suitable to use as a pch argument to the points function. If the argument is a vector, the length should be the same as the number of columns in x. If the argument is a matrix, it should have the same dims as x. The suggested vector has been selected to work with RSVGTipsDevice tool tips.

segments.args

A list of arguments to pass to the segments function.

points.args

A list of arguments to pass to the points function.

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 x.

groups

A factor that indicates the group of each row in x. Groups are printed under a common header.

tiptext

If you are using the RSVGTipsDevice library for rendering, you can include an array of the dimensions of x with another dimension of length 2. For example, if there are 4 observations and 2 strata, the array should be 4 by 2 by 2. The tiptext[i, j, 1] entry will be the first line of the tool tip for the data in x[i, j]. Likewise for the second row of the tool tip.

include.legend

Should a legend be included?

legend.title

An optional title to attach to the legend.

...

Additional arguments to pass to plot.default.

Details

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.

See Also

plot.xbal, xBalance, segments, points

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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

RItools:::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")

markmfredrickson/RItools documentation built on Oct. 3, 2018, 1:07 p.m.