Skip to contents

Compute 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?"

Usage

bhattacharyya_coef(x, y = NULL, bins = 50L)

Arguments

x, y

Numeric vectors. If x is a multisitedgp_data object and y is NULL, x$z_j is compared with the target G's quantile grid.

bins

Integer. Number of histogram bins. Default 50L.

Value

A scalar double in [0, 1].

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 .

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