Compute several balance measures to check whether the covariate distributions are balanced across treatment arms.

balance_measures(X, D)

Arguments

X

Covariate matrix (no intercept).

D

Treatment assignment vector.

Value

Prints LATEX code in the console.

Details

For each covariate in X, balance_measures computes sample averages and standard deviations for both treatment arms. Additionally, two balance measures are computed:

Norm. Diff.

Normalized differences, computed as the differences in the means of each covariate across treatment arms, normalized by the sum of the within-arm variances. They provide a measure of the discrepancy between locations of the covariate distributions across treatment arms.

Log S.D.

Log ratio of standard deviations are computed as the logarithm of the ratio of the within-arm standard deviations. They provide a measure of the discrepancy in the dispersion of the covariate distributions across treatment arms.

Compilation of the LATEX code requires the following packages: booktabs, float, adjustbox.

Author

Elena Dal Torrione, Riccardo Di Francesco

Examples

## Generate data.
set.seed(1986)

n <- 1000
k <- 3

X <- matrix(rnorm(n * k), ncol = k)
colnames(X) <- paste0("x", seq_len(k))
D <- rbinom(n, size = 1, prob = 0.5)
mu0 <- 0.5 * X[, 1]
mu1 <- 0.5 * X[, 1] + X[, 2]
y <- mu0 + D * (mu1 - mu0) + rnorm(n)

## Print table.
balance_measures(X, D)
#> \begingroup
#>   \setlength{\tabcolsep}{8pt}
#>   \renewcommand{\arraystretch}{1.1}
#>   \begin{table}[H]
#>     \centering
#>     \begin{adjustbox}{width = 0.75\textwidth}
#>     \begin{tabular}{@{\extracolsep{5pt}}l c c c c c c}
#>     \\[-1.8ex]\hline
#>     \hline \\[-1.8ex]
#>     & \multicolumn{2}{c}{Treated} & \multicolumn{2}{c}{Controls} & \multicolumn{2}{c}{Overlap measures} \\ \cmidrule{6-7}
#>     & \multicolumn{2}{c}{($n_t =  502 $)} & \multicolumn{2}{c}{($n_c = 498 $)} & \\ \cmidrule{2-5}
#>     & Mean & (S.D.) & Mean & (S.D.) & $\hat{\Delta}_j$ & $\hat{\Gamma}_j$ \\
#>     \addlinespace[2pt]
#>     \hline \\[-1.8ex] 
#> 
#>     \texttt{x1} & 0.080 & (1.011) & 0.028 & (1.004) & 0.052 & 0.007 \\ 
#>     \texttt{x2} & -0.005 & (1.026) & -0.009 & (0.999) & 0.003 & 0.027 \\ 
#>     \texttt{x3} & -0.026 & (1.015) & 0.013 & (0.979) & -0.039 & 0.036 \\ 
#> 
#>     \addlinespace[3pt]
#>     \\[-1.8ex]\hline
#>     \hline \\[-1.8ex]
#>     \end{tabular}
#>     \end{adjustbox}
#>     \caption{Balance between treatment and control groups. The last two columns report the estimated normalized differences ($\hat{\Delta}_j$) and logarithms of the ratio of standard deviations ($\hat{\Gamma}_j$).}
#>     \label{table:descriptive.stats}
#>     \end{table}
#> \endgroup