Custom function to visualize the balance between treatment and control groups

balance_scatter_custom(
  matched_set_list,
  set.names = NULL,
  show.legend = TRUE,
  legend.title = "Type",
  legend.position = "right",
  xlim = c(0, 0.8),
  ylim = c(0, 0.8),
  main = "Standardized Mean Difference of Covariates",
  pchs = NULL,
  dot.size = NULL,
  covariates,
  data,
  x.axis.label = "Before Refinement",
  y.axis.label = "After Refinement",
  theme_use = causalverse::ama_theme(),
  ...
)

Arguments

matched_set_list

List of matched sets

set.names

Vector of names for matched sets. Defaults to NULL.

show.legend

Boolean to determine if legend should be shown. Defaults to TRUE.

legend.title

Legend title. Defaults to "Type".

legend.position

Position of legend. Defaults to "right".

xlim

Vector defining x-axis limits. Defaults to c(0, 0.8).

ylim

Vector defining y-axis limits. Defaults to c(0, 0.8).

main

Main title for the plot. Defaults to "Standardized Mean Difference of Covariates".

pchs

Plot characters. Defaults to NULL.

dot.size

Size of dots in the scatter plot. Defaults to NULL.

covariates

Covariates for calculating balance.

data

Dataset for balance calculation.

x.axis.label

x-axis label. Defaults to "Before Refinement".

y.axis.label

y-axis label. Defaults to "After Refinement".

theme_use

Custom theme that follows ggplots2. Defaults to causalverse::ama_theme().

...

Additional arguments passed to the labs() function

Value

ggplot object

Examples

if (FALSE) {
library(PanelMatch)
# Maha 4-year lag, up to 5 matches
PM.results.maha.4lag.5m <- PanelMatch::PanelMatch(
   lag = 4,
   time.id = "year",
   unit.id = "wbcode2",
   treatment = "dem",
   refinement.method = "mahalanobis",
   data = PanelMatch::dem,
   match.missing = TRUE,
   covs.formula = ~ I(lag(tradewb, 1:4)) + I(lag(y, 1:4)),
   size.match = 5,
   qoi = "att",
   outcome.var = "y",
   lead = 0:4,
   forbid.treatment.reversal = FALSE,
   use.diagonal.variance.matrix = TRUE
)

# Maha 4-year lag, up to 10 matches
PM.results.maha.4lag.10m <- PanelMatch::PanelMatch(
   lag = 4,
   time.id = "year",
   unit.id = "wbcode2",
   treatment = "dem",
   refinement.method = "mahalanobis",
   data = PanelMatch::dem,
   match.missing = TRUE,
   covs.formula = ~ I(lag(tradewb, 1:4)) + I(lag(y, 1:4)),
   size.match = 10,
   qoi = "att",
   outcome.var = "y",
   lead = 0:4,
   forbid.treatment.reversal = FALSE,
   use.diagonal.variance.matrix = TRUE
)

# Using the function
balance_scatter_custom(
   matched_set_list = list(PM.results.maha.4lag.5m$att, PM.results.maha.4lag.10m$att),
   set.names = c("Maha 4 Lag 5 Matches", "Maha 4 Lag 10 Matches"),
   data = dem,
   covariates = c("y", "tradewb")
)
}