Skip to contents

Reports standardised mean differences (SMD), variance ratios, and Kolmogorov-Smirnov statistics for each covariate. For a richer covariate-balance report (including continuous + categorical handling and Love-plot rendering), see cobalt::bal.tab / cobalt::love.plot.

Usage

morie_matching_balance(
  data,
  treatment,
  covariates,
  weights = NULL,
  threshold = 0.1
)

Arguments

data

Data frame.

treatment

Binary treatment column name.

covariates

Character vector of covariates.

weights

Optional column name of matching / weighting weights.

threshold

Absolute-SMD threshold for the balanced flag.

Value

A list of class morie_balance_result with balance_table (a data frame) and scalar summaries overall_balance, max_smd, balanced.

Examples

# \donttest{
set.seed(1)
df <- data.frame(y = rnorm(200), d = rbinom(200, 1, 0.4),
                 x1 = rnorm(200), x2 = rnorm(200))
morie_matching_balance(df, "d", c("x1", "x2"))
#> $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"                
# }