Skip to contents

Standardised mean difference of every design column (factors expanded to drop-first dummies) in the raw sample, under inverse-propensity weights, and in the 1:1 nearest-neighbour matched sample (greedy, without replacement, on the logit propensity with caliper caliper_sd * SD(logit e); treated units in random order). \(|SMD| > 0.1\) is the usual flag for meaningful imbalance (Austin 2011).

Usage

morie_otis_balance(
  df,
  treatment,
  covariates,
  outcome = NULL,
  caliper_sd = 0.2,
  eps = 0.02,
  seed = 123L
)

Arguments

df

A data frame containing treatment, outcome, and all covariates (rows with NAs in these columns are dropped).

treatment

Name of the binary treatment column. Strings "Yes"/"No" (case-insensitive) are auto-binarised; numeric columns are coerced with NA -> 0.

covariates

Character vector of covariate names. Character / factor columns are converted to drop-first dummies.

outcome

Optional outcome column; rows missing it are dropped too.

caliper_sd

Caliper in SDs of the logit propensity, or NULL for none (default 0.2).

eps

Numeric in \((0, 0.5)\); propensity clip bound (default 0.02).

seed

Seed for the order treated units are matched in (default 123).

Value

Data frame with covariate, smd_raw, smd_ipw, smd_psm.

References

Austin, P. C. (2011). An introduction to propensity score methods for reducing the effects of confounding in observational studies. Multivariate Behavioral Research 46(3), 399-424.

Examples

set.seed(1)
n <- 300L
x <- rnorm(n)
g <- sample(c("a", "b"), n, TRUE)
d <- rbinom(n, 1, plogis(0.8 * x))
morie_otis_balance(data.frame(d = d, x = x, g = g), "d", c("x", "g"))
#>   covariate     smd_raw    smd_ipw     smd_psm
#> 1         x  0.85055375 0.04046425  0.01823001
#> 2        gb -0.07550081 0.05022479 -0.04153933