ks_stat {twosamples} | R Documentation |
Performs a permutation based two sample test using the Kolmogorov-Smirnov test statistic (ks_stat).
ks_stat(a, b, power = 1) ks_test(a, b, nboots = 2000, p = default.p)
a |
a vector of numbers |
b |
a vector of numbers |
power |
power to raise test stat to |
nboots |
Number of bootstrap iterations |
p |
power to raise test stat to |
The KS test compares two ECDFs by looking at the maximum difference between them. Formally – if E is the ECDF of sample 1 and F is the ECDF of sample 2, then KS = max |E(x)-F(x)| for values of x in the joint sample. The test p-value is calculated by randomly resampling two samples of the same size using the combined sample.
Output is a length 2 Vector with test stat and p-value in that order. That vector has 3 attributes – the sample sizes of each sample, and the number of bootstraps performed for the pvalue.
ks_stat
: Kolmogorov-Smirnov test statistic
ks_test
: Permutation based two sample Kolmogorov-Smirnov test
vec1 = rnorm(20) vec2 = rnorm(20,4) ks_test(vec1,vec2)