plot.balancetest: Plot of balance across multiple strata

View source: R/plot.balancetest.R

plot.balancetestR Documentation

Plot of balance across multiple strata

Description

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 'balancetest'
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.

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.

Value

A ggplot2 object that can be further manipulated (e.g., to set the colors or text).

See Also

balanceTest, ggplot


RItools documentation built on June 22, 2024, 9:06 a.m.