Skip to contents

Compute 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.

Usage

ks_distance(x, y = NULL)

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.

Value

A scalar double in [0, 1].

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 .

Examples

ks_distance(rnorm(200), rnorm(200))    # small
#> [1] 0.065
dat <- sim_multisite(J = 50L, seed = 1L)
ks_distance(dat)
#> [1] 0.14