get_covariate_balance: Calculate covariate balance

View source: R/get_covariate_balance.R

get_covariate_balanceR Documentation

Calculate covariate balance

Description

Calculate covariate balance for user specified covariates across matched sets. Balance is assessed by taking the average of the difference between the values of the specified covariates for the treated unit(s) and the weighted average of the control units across all matched sets. Results are standardized and are expressed in standard deviations. Balance is calculated for each period in the specified lag window.

Usage

get_covariate_balance(
  matched.sets,
  data,
  covariates,
  use.equal.weights = FALSE,
  plot = FALSE,
  reference.line = TRUE,
  legend = TRUE,
  ylab = "SD",
  include.treatment.period = TRUE,
  legend.position = "topleft",
  ...
)

Arguments

matched.sets

A matched.set object

data

The time series cross sectional data set (as a data.frame object) used to produce the matched.set object. This data set should be identical to the one passed to PanelMatch() and PanelEstimate() to ensure consistent results.

covariates

a character vector, specifying the names of the covariates for which the user is interested in calculating balance.

use.equal.weights

logical. If set to TRUE, then equal weights will be assigned to control units, rather than using whatever calculated weights have been assigned. This is helpful for assessing the improvement in covariate balance as a result of refining the matched sets.

plot

logical. When TRUE, a plot showing the covariate balance calculation results will be shown. When FALSE, no plot is made, but the results of the calculations are returned. default is FALSE

reference.line

logical indicating whether or not a horizontal line should be present on the plot at y = 0. Default is TRUE.

legend

logical indicating whether or not a legend identifying the variables should be included on the plot. Default is TRUE.

ylab

Label for y axis. Default is "SD". This is the same as the ylab argument to plot().

include.treatment.period

logical. Default is TRUE. When TRUE, covariate balance measures for the period during which treatment occurs is included. These calculations are not included when FALSE. Users may wish to leave this period off in some circumstances. For instance, one would expect covariate balance to be poor during this period when treatment is continuous and a lagged outcome is included in the refinement formula.

legend.position

position of legend. See documentation for graphics::legend. Default is "topleft"

...

Additional graphical parameters to be passed to the plot function in base R.

Examples

dem.sub <- dem[dem[, "wbcode2"] <= 100, ]
# create subset of data for simplicity
#add some additional data to data set for demonstration purposes
dem.sub$rdata <- runif(runif(nrow(dem.sub)))
pm.obj <- PanelMatch(lead = 0:3, lag = 4, time.id = "year", unit.id = "wbcode2", treatment = "dem",
                    outcome.var ="y", refinement.method = "ps.match",
                    data = dem.sub, match.missing = TRUE,
                    covs.formula = ~ tradewb + rdata + I(lag(tradewb, 1:4)) + I(lag(y, 1:4)),
                    size.match = 5, qoi = "att")
get_covariate_balance(pm.obj$att, dem.sub, covariates = c("tradewb", "rdata"),
                         ylim = c(-2,2))


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