balance_scatter_custom.Rd
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(),
...
)
List of matched sets
Vector of names for matched sets. Defaults to NULL.
Boolean to determine if legend should be shown. Defaults to TRUE.
Legend title. Defaults to "Type".
Position of legend. Defaults to "right".
Vector defining x-axis limits. Defaults to c(0, 0.8).
Vector defining y-axis limits. Defaults to c(0, 0.8).
Main title for the plot. Defaults to "Standardized Mean Difference of Covariates".
Plot characters. Defaults to NULL.
Size of dots in the scatter plot. Defaults to NULL.
Covariates for calculating balance.
Dataset for balance calculation.
x-axis label. Defaults to "Before Refinement".
y-axis label. Defaults to "After Refinement".
Custom theme that follows ggplots2. Defaults to causalverse::ama_theme().
Additional arguments passed to the labs() function
ggplot object
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")
)
}