Kolmogorov_dist {fmx} | R Documentation |
One-Sample Kolmogorov Distance
Description
To calculate the one-sample Kolmogorov distance between observations and a distribution.
Usage
Kolmogorov_dist(x, null, alternative = c("two.sided", "less", "greater"), ...)
Arguments
x |
|
null |
cumulative distribution function |
alternative |
character scalar,
alternative hypothesis, either |
... |
additional arguments of |
Details
Function Kolmogorov_dist is different from ks.test in the following aspects
-
Ties in observations are supported. The step function of empirical distribution is inspired by ecdf. This is superior than
(0:(n - 1))/n
in ks.test. -
Discrete distribution (with discrete observation) is supported.
-
Discrete distribution (with continuous observation) is not supported yet. This will be an easy modification in future.
-
Only the one-sample Kolmogorov distance, not the one-sample Kolmogorov test, is returned, to speed up the calculation.
Value
Function Kolmogorov_dist returns a numeric scalar.
Examples
# from ?stats::ks.test
x1 = rnorm(50)
ks.test(x1+2, y = pgamma, shape = 3, rate = 2)
Kolmogorov_dist(x1+2, null = pgamma, shape = 3, rate = 2) # exactly the same
# discrete distribution
x2 <- rnbinom(n = 1e2L, size = 500, prob = .4)
suppressWarnings(ks.test(x2, y = pnbinom, size = 500, prob = .4)) # warning on ties
Kolmogorov_dist(x2, null = pnbinom, size = 500, prob = .4) # wont be the same