balance_scatter: balance_scatter

View source: R/balance_scatter.R

balance_scatterR Documentation

balance_scatter

Description

Visualizing the standardized mean differences for covariates via a scatter plot.

Usage

balance_scatter(
  matched_set_list,
  xlim = c(0, 0.8),
  ylim = c(0, 0.8),
  main = "Standardized Mean Difference of Covariates",
  pchs = c(2, 3),
  covariates,
  data,
  x.axis.label = "Before refinement",
  y.axis.label = "After refinement",
  ...
)

Arguments

matched_set_list

a list of one or more matched.set objects

xlim

xlim of the scatter plot. This is the same as the xlim argument in plot()

ylim

ylim of the scatter plot. This is the same as the ylim argument in plot()

main

title of the scatter plot. This is the same as the main argument in plot()

pchs

one or more pch indicators for the symbols on the scatter plot. You should specify a pch symbol for each matched.set you specify in matched_set_list. See plot() for more information

covariates

variables for which balance is displayed

data

the same time series cross sectional data set used to create the matched sets.

x.axis.label

x axis label

y.axis.label

y axis label

...

optional arguments to be passed to plot()

Details

balance_scatter visualizes the standardized mean differences for each covariate. Although users can use the scatter plot in a variety of ways, it is recommended that the x-axis refers to balance for covariates before refinement, and y-axis refers to balance after refinement. Users can utilize parameters powered by plot() in base R to further customize the figure.

Author(s)

In Song Kim <insong@mit.edu>, Erik Wang <haixiao@Princeton.edu>, Adam Rauh <amrauh@umich.edu>, and Kosuke Imai <imai@harvard.edu>

Examples

dem.sub <- dem[dem[, "wbcode2"] <= 100, ]
# create subset of data for simplicity
# get a matched set without refinement
sets0 <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2",
                    treatment = "dem", refinement.method = "none",
                    data = dem.sub, match.missing = FALSE,
                    size.match = 5, qoi = "att",
                    outcome.var = "y",
                    lead = 0:4, forbid.treatment.reversal = FALSE)

# get a matched set with refinement using propensity score matching, setting the
# size of matched set to 5
sets1 <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2",
                    treatment = "dem", refinement.method = "ps.match",
                    data = dem.sub, match.missing = FALSE,
                    covs.formula = ~ tradewb,
                    size.match = 5, qoi = "att",
                    outcome.var = "y",
                    lead = 0:4, forbid.treatment.reversal = FALSE)

# get another matched set with refinement using propensity score weighting
sets2 <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2",
                    treatment = "dem", refinement.method = "ps.weight",
                    data = dem.sub, match.missing = FALSE,
                    covs.formula = ~ tradewb,
                    size.match = 10, qoi = "att",
                    outcome.var = "y",
                    lead = 0:4, forbid.treatment.reversal = FALSE)


# use the function to produce the scatter plot
balance_scatter(matched_set_list = list(sets0$att, sets1$att, sets2$att),
              data = dem.sub,
              covariates = c("y", "tradewb"))
# add legend
legend(x = 0, y = 0.8,
legend = c("mahalanobis",
           "PS weighting"),
y.intersp = 0.65,
x.intersp = 0.3,
xjust = 0,
pch = c(1, 3), pt.cex = 1,
bty = "n", ncol = 1, cex = 1, bg = "white")




PanelMatch documentation built on June 22, 2024, 10:32 a.m.