# two-sample Kolmogorov-Smirnov test p-value in R confusion

I'm confused about the appropriate interpretation of p-values returned by the two-sample Kolmogorov-Smirnov test (ks.test) in R.

In slide 23 of this presentation about non-parametric two-sample tests, the author states that when analyzing the ks.test results:

ks.test(male, female)
Two-sample Kolmogorov-Smirnov test
data: male and female
D = 0.8333, p-value = 0.02597


the p-value

needs to be multiplied by 2 for a 2-tail test. Thus, P = 0.05194

Is that true?

If we used the original p = 0.02597, we would reject the hypothesis that the distributions similar, because p < 0.05, correct? Whereas if we multiply it by 2, the p would suggest that there is no difference between distributions, since p > 0.05?

What am I missing?

• The manual page for ks.test documents an optional parameter alternative that specifies the kind of test. Why don't you use it and see what the answer is? (Or you could just trust the account of the test in the "Details" section of that page.)
– whuber
Jul 9, 2014 at 21:05
• I looked the example in the ks.test() help file. Whether I used the option 'alternative="two-sided"' or not, the resulting p-value was the same. Which means no multiplication is needed, correct? Why did the author of slides claim it was, then? Jul 9, 2014 at 21:35
• alternative="two-sided" is the default, which is why nothing changed. Try the other alternatives. I won't speculate on what the author of that presentation might have been thinking.
– whuber
Jul 9, 2014 at 21:37
• The other alternatives are less and greater which is not what I need. My goal is to simply check if two distributions have "similar shape" so I'll take the p-vale produced by the ks.test at, well, face-value. Jul 9, 2014 at 21:42

No, it's wrong. The default Kolmogorov-Smirnov in R is already two sided (i.e. already tests $F_X\neq F_Y$ rather than $F_X<F_Y$ or $F_X>F_Y$ (in all three cases, we should add "somewhere").
It's just unnecessary, since the ks.test function will happily calculate two-tailed p-values for us without doing a thing -- in fact we have to explicitly ask for a one-tailed one.