Problems with ks.test and ties

I have a distribution, for example:

d #[1] 4 22 15 5 9 5 11 15 21 14 14 23 6 9 17 2 7 10 4 

Or, the vector d in dput format.

d <- c(4, 22, 15, 5, 9, 5, 11, 15, 21, 14, 14, 23, 6, 9, 17, 2, 7, 10, 4) 

And when I apply the ks.test,:

gamma <- ks.test(d, "pgamma", shape = 3.178882, scale = 3.526563) 

This gives the following warning:

Warning message: In ks.test(d, "pgamma", shape = 3.178882, scale = 3.526563) : ties should not be present for the Kolmogorov-Smirnov test

I tried put unique(d), but obvious my data reduce the values and I wouldn't like this happen.
And the others manners and examples online, this example happen too, but the difference is the test show some results with the warning message, not only the message without values of ks.test.

Some help?

3

1 Answer

In gamma you can find your result, warning message is not blocking

d <- c(4, 22, 15, 5, 9, 5, 11, 15, 21, 14, 14, 23, 6, 9, 17, 2, 7, 10, 4) gamma <- ks.test(d, "pgamma", shape = 3.178882, scale = 3.526563) 

Warning message: In ks.test(d, "pgamma", shape = 3.178882, scale = 3.526563) : ties should not be present for the Kolmogorov-Smirnov test

gamma One-sample Kolmogorov-Smirnov test data: d D = 0.14549, p-value = 0.816 alternative hypothesis: two-sided 

You find an explanation of the warning in 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.

As you can see some rounding is applied and the test is "approximately" valid.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like