Compute Bhattacharyya coefficient between empirical distributions
Source:R/diagnostics-core.R
bhattacharyya_coef.RdCompute the Bhattacharyya coefficient
\(\mathrm{BC}(p, q) = \sum_b \sqrt{p_b\,q_b}\) — a similarity measure
in [0, 1] where 1 is identical-shape and 0 is disjoint-support.
Group C diagnostic (distributional fit — the third of Dr. Chen's
four questions): "Does the realized effect distribution match the
target G shape?"
Details
For multisitedgp_data inputs, the realized z_j is compared against
a deterministic reference quantile grid for attr(x, "design")$true_dist.
Higher BC = closer agreement. Default-threshold rubric flags BC < 0.85
as a fit warning at the typical applied setting (\(J = 50\),
bins = 50).
References
Lee, J., Che, J., Rabe-Hesketh, S., Feller, A., & Miratrix, L. (2025). Improving the estimation of site-specific effects and their distribution in multisite trials. Journal of Educational and Behavioral Statistics, 50(5), 731–764. doi:10.3102/10769986241254286 .
See also
ks_distance for a tail-sensitive Group C complement;
scenario_audit for the top-of-funnel sweep; the
A3 Diagnostics
in practice vignette.
Other family-diagnostics:
compute_I(),
compute_kappa(),
compute_shrinkage(),
default_thresholds(),
feasibility_index(),
heterogeneity_ratio(),
informativeness(),
ks_distance(),
mean_shrinkage(),
realized_rank_corr(),
realized_rank_corr_marginal(),
scenario_audit()
Examples
bhattacharyya_coef(rnorm(200), rnorm(200)) # ≈ 1
#> [1] 0.8815463
dat <- sim_multisite(J = 50L, true_dist = "Gaussian", seed = 1L)
bhattacharyya_coef(dat)
#> [1] 0.8014348