Learn R Programming

cobalt (version 1.3.0)

bal.plot: Generate Univariate Balance Plots

Description

Generates density plots, bar graphs, or scatterplots displaying distributional balance between treatment and covariates using ggplot2.

Usage

bal.plot(obj, var.name, ..., un = FALSE, which.sub = NULL, cluster = NULL, which.cluster = NULL)

Value

A "ggplot" object, returned invisbly.

Additional Arguments

bal.plot() works like bal.tab() in that it can take a variety of types of inputs and yield the same output for each. Depending on what kind of input is given, different additional paramaters are required in .... For details on what is required and allowed for each additional input and their defaults, see the help file for the bal.tab method associated with the input. The following are the required and optional additional arguments based on each input type: For matchit objects: None For ps objects: full.stop.method (optional; see defaults). For Match objects: formula and data or covs and treat. For CBPS objects: None For formulas: data, weights, distance (optional), method (optional; see defaults) For data frames: treat, data (optional), weights, distance (optional), method (optional; see defaults)

Details

bal.plot() uses ggplot() from the ggplot2 package, and (invisibly) returns a "ggplot" object. This mean that users can edit aspects of the plot using ggplot2 syntax. For binary treatments with continuous covariates or continuous treatments with categorical or binary covariates, density plots are created using ggplot2's geom_density() method; for binary treatments with binary covariates, bar graphs are created using ggplot2's geom_bar() method; for continuous treatments with continuous covariates, scatterplots are created using ggplot2's geom_point() method.

For continuous treatments with continuous covariates, three additional lines are presented for aid in balance assessment. The dashed blue line is the linear fit line. The solid blue line is a Loess fit curve generated with ggplot2's default geom_smooth() method. The solid black line is a horizontal reference line intercepting the (weighted) treatment mean. Proximity of the fit lines to the reference line is indicative of independence between the covariate and treatment variable.

See Also

bal.tab

Examples

Run this code
library(MatchIt); data("lalonde", package = "cobalt")

#Nearest Neighbor Matching
m.out <- matchit(treat ~ age + educ + black + hispan + 
                 married + nodegree + re74 + re75, 
                 data = lalonde)

bal.plot(m.out, "age")
bal.plot(m.out, "married")

Run the code above in your browser using DataLab