Compute Kolmogorov-Smirnov distance between empirical distributions
Source:R/diagnostics-core.R
ks_distance.RdCompute the Kolmogorov-Smirnov distance \(D = \sup_t |F_x(t) - F_y(t)|\) — a tail-sensitive complement to the Bhattacharyya coefficient. Group C diagnostic (distributional fit): use KS when worst single-quantile mismatch matters; use BC for overall shape.
Details
Lower KS = closer agreement. KS < 0.10 corresponds to two-sample KS
p > 0.05 at \(J = 50\), the package's default flag threshold.
For multisitedgp_data inputs, z_j is compared against the target G's
deterministic reference quantile grid (same protocol as
bhattacharyya_coef).
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
bhattacharyya_coef for the shape-similarity Group C
companion; the A3
Diagnostics in practice vignette.
Other family-diagnostics:
bhattacharyya_coef(),
compute_I(),
compute_kappa(),
compute_shrinkage(),
default_thresholds(),
feasibility_index(),
heterogeneity_ratio(),
informativeness(),
mean_shrinkage(),
realized_rank_corr(),
realized_rank_corr_marginal(),
scenario_audit()
Examples
ks_distance(rnorm(200), rnorm(200)) # small
#> [1] 0.065
dat <- sim_multisite(J = 50L, seed = 1L)
ks_distance(dat)
#> [1] 0.14