[R] ks.test ; impossible to calculate exact exact value with ex-aequos

Ted Harding ted@h@rding @ending from wl@ndre@@net
Mon Dec 10 23:44:57 CET 2018


On Mon, 2018-12-10 at 22:17 +0100, Fatma Ell wrote:
> Dear all,
> I'm trying to use ks.test in order to compare two curve. I've 0 values i
> think this is why I have the follonwing warnings :impossible to calculate
> exact exact value with  ex-aequos
> 
> a=c(3.02040816326531, 7.95918367346939, 10.6162790697674, 4.64150943396226,
> 1.86538461538462, 1.125, 1.01020408163265, 1.2093023255814,
> 0.292452830188679,
> 0, 0, 0)
> b=c(2.30769230769231, 4.19252873563218, 5.81924882629108, 6.2248243559719,
> 5.02682926829268, 4.50728862973761, 3.61741424802111, 5.05479452054795,
> 3.68095238095238, 1.875, 5.25, 0)
> 
> ks.test(a,b)
> 
> data:  a and b
> D = 0.58333, p-value = 0.0337
> alternative hypothesis: two-sided
> 
> Warning message:
> In ks.test(a, b) :
> impossible to calculate exact exact value with ex-aequos
> 
> Does the p-value is correct ? Otherwise, how to solve this issue ?
> Thanks a lot.

The warning arises, not because you have "0" values as such,
but because there are repeated values (which happen to be 0).

The K-S test is designed for continuous random variables, for
which the probability of repeated values is (theoretically) zero:
theoretically, they can't happen.

>From the help page ?ks.test :

"The presence of ties always generates a warning, since continuous
distributions do not generate them. If the ties arose from
rounding the tests may be approximately valid, but even modest
amounts of rounding can have a significant effect on the
calculated statistic."



in view of the fact that your sample 'a' has three zeros along with
nine other vauwes which are all different from 0 (and all *very*
different from 0 except for 0.292452830188679), along with the fact
that your sample 'b' has 11 values all *very* different from 0.
and pne finall value equal to 0; together also with the fact that
in each sample the '0' values occur at the end, stringly suggests
that the data source is not such that a K-D test is auitasble.

The K-S test is a non-parametric test for whether
  a) a given sample comes from na given kind of distribiution;
or
  v) two samples are drwn from the same distribition.
In either case, it is assumed that the sample values are drawn
independently of each other; if there is some reason why they
may not be independent of each other, the test os not valid.

You say "I'm trying to use ks.test in order to compare two curve".
When I ezecute
  plot(a)
  plot(b)
on your data, I see (approximately) in each case a rise from a
medium vale (~2 or ~3) to a higher vale {~6 or ~10) followed
by a decline down to an exact 0.

This is not the sort of situation that the K-S test is for!
Hoping this helps,
Ted.



More information about the R-help mailing list