Skip to contents

Returns a data frame suitable for plotting absolute SMDs before and after matching. For a publication-ready plot, pass the same matchit object to cobalt::love.plot.

Usage

morie_matching_love_plot_data(
  unmatched_data,
  matched_data,
  treatment,
  covariates,
  weights_col = NULL
)

Arguments

unmatched_data, matched_data

Data frames.

treatment

Binary treatment column name.

covariates

Character vector of covariates.

weights_col

Optional column of matching weights in matched_data.

Value

A data frame with columns covariate, smd_before, smd_after, abs_smd_before, abs_smd_after.

Examples

# \donttest{
set.seed(1)
df <- data.frame(y = rnorm(200), d = rbinom(200, 1, 0.4),
                 x1 = rnorm(200), x2 = rnorm(200))
res <- morie_matching_nearest_neighbor(df, "d", c("x1", "x2"))
morie_matching_love_plot_data(df, res$matched_data,
                              "d", c("x1", "x2"))
#>   covariate smd_before  smd_after abs_smd_before abs_smd_after
#> 1        x1 0.08978223 0.01147788     0.08978223    0.01147788
#> 2        x2 0.21729769 0.08026628     0.21729769    0.08026628
# }