Skip to contents

Custom function to visualize the balance between treatment and control groups

Usage

balance_scatter_custom(
  pm_result_list,
  panel.data,
  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,
  x.axis.label = "Before Refinement",
  y.axis.label = "After Refinement",
  theme_use = causalverse::ama_theme(),
  ...
)

Arguments

pm_result_list

List of PanelMatch result objects (output of PanelMatch::PanelMatch()).

panel.data

A PanelData object created by PanelMatch::PanelData().

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.

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) { # \dontrun{
library(PanelMatch)
pd <- PanelData(panel.data = dem, unit.id = "wbcode2",
                time.id = "year", treatment = "dem", outcome = "y")

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

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

# Using the function
balance_scatter_custom(
   pm_result_list = list(PM.results.5m, PM.results.10m),
   panel.data = pd,
   set.names = c("Maha 4 Lag 5 Matches", "Maha 4 Lag 10 Matches"),
   covariates = c("y", "tradewb")
)
} # }