Skip to contents

Compares balance before and after matching and reports percent bias reduction, count of balanced covariates, and overlap statistics.

Usage

morie_matching_quality(
  unmatched_data,
  matched_data,
  treatment,
  covariates,
  weights = NULL
)

Arguments

unmatched_data, matched_data

Data frames.

treatment

Binary treatment column.

covariates

Character vector of covariates.

weights

Optional column of matching weights in matched_data.

Value

A list with balance_before, balance_after, bias_reduction, mean_bias_reduction, pct_balanced_before, pct_balanced_after, n_obs_before, n_obs_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_quality(df, res$matched_data, "d", c("x1", "x2"))
#> $balance_before
#> $balance_table
#>   covariate mean_treated mean_control        smd    abs_smd variance_ratio
#> 1        x1  0.061404608  -0.03624282 0.08978223 0.08978223      1.1009337
#> 2        x2  0.003342348  -0.21859021 0.21729769 0.21729769      0.9771198
#>     ks_stat ks_p_value
#> 1 0.1085342  0.5597990
#> 2 0.1498322  0.1941478
#> 
#> $overall_balance
#> [1] 0.15354
#> 
#> $max_smd
#> [1] 0.2172977
#> 
#> $balanced
#> [1] FALSE
#> 
#> attr(,"class")
#> [1] "morie_balance_result" "list"                
#> 
#> $balance_after
#> $balance_table
#>   covariate mean_treated mean_control        smd    abs_smd variance_ratio
#> 1        x1  0.061404608   0.04909703 0.01147788 0.01147788       1.169659
#> 2        x2  0.003342348  -0.07685001 0.08026628 0.08026628       1.068134
#>     ks_stat ks_p_value
#> 1 0.1034483  0.7436107
#> 2 0.1034483  0.7436107
#> 
#> $overall_balance
#> [1] 0.04587208
#> 
#> $max_smd
#> [1] 0.08026628
#> 
#> $balanced
#> [1] TRUE
#> 
#> attr(,"class")
#> [1] "morie_balance_result" "list"                
#> 
#> $bias_reduction
#> $bias_reduction$x1
#> [1] 87.21587
#> 
#> $bias_reduction$x2
#> [1] 63.0616
#> 
#> 
#> $mean_bias_reduction
#> [1] 75.13874
#> 
#> $pct_balanced_before
#> [1] 50
#> 
#> $pct_balanced_after
#> [1] 100
#> 
#> $n_obs_before
#> [1] 200
#> 
#> $n_obs_after
#> [1] 174
#> 
# }