Computes standardized mean differences (SMD) between two groups for each
covariate in X. Returns one row per covariate with group means,
standard deviations, raw and absolute SMD, and conventional balance
thresholds.
Arguments
- group
Integer (or coercible) binary group indicator. Must have exactly two distinct non-missing values.
- X
Data frame of baseline covariate columns.
- w
Optional numeric case-weight vector. When supplied, weighted group means (
wmean_0,wmean_1) and weighted SMD (wsmd) are added. Weighted SMD uses the unweighted pooled SD as the standardizer (Rubin simplification).
Value
A data.frame of class c("smd_balance_table",
"data.frame") with one row per covariate and columns:
attribute, n_group_0, n_group_1,
mean_0, sd_0, mean_1, sd_1,
smd, abs_smd,
balanced_020 (abs_smd < 0.20),
balanced_010 (abs_smd < 0.10),
wmean_0, wmean_1, wsmd, wabs_smd,
wbalanced_020, wbalanced_010
(weighted variants; NA when w = NULL).
Details
SMD is a conventional companion diagnostic, not the oda
balance objective. The primary oda balance assessment uses
oda_balance_table. This function is intended for comparison
with non-ODA balance reports.
No p-values are computed. SMD is a descriptive statistic. For a variable
with zero within-group variance in both groups, smd is NA.
Examples
group <- c(rep(0L, 30), rep(1L, 30))
X <- data.frame(age = c(rep(45, 30), rep(55, 30)),
score = rnorm(60, 50, 10))
smd_balance_table(group, X)
#> attribute n_group_0 n_group_1 mean_0 sd_0 mean_1 sd_1 smd
#> 1 age 30 30 45.00000 0.00000 55.00000 0.000000 NA
#> 2 score 30 30 47.15789 10.40146 49.05927 7.815423 0.2066766
#> abs_smd balanced_020 balanced_010 wmean_0 wmean_1 wsmd wabs_smd
#> 1 NA NA NA NA NA NA NA
#> 2 0.2066766 FALSE FALSE NA NA NA NA
#> wbalanced_020 wbalanced_010
#> 1 NA NA
#> 2 NA NA