# [R] question regarding ks.test()

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon Sep 15 21:44:39 CEST 2003

```Rajarshi Guha wrote:
>
> Hi,
>   I'm using the ks.test() on two vectors. I looked up the reference and
> also coded up a version of the two sample Smirnov test. My question is
> that how can I decide from the output of R that the two vectors x & y
> come from the same distribution?

Strictly speaking, you cannot. You are testing H0: "same distribution"
against H1: "different distribution" in case "two.sided",
so you can only "decide" the alternative is true with probability
1-alpha, if p < alpha.

> Am I correct in assuming that smaller D values indicate that they come
> from the same distribution?

Right. For D=0 the ecdfs are equal to each other under the two.sided
hypothesis.

> In addition how can I use the p value that is supplied in the output?

As all other p values? You can reject if p < alpha. Before going further
testing, see the help page for notes on the accuracy of the p-value.

> In my code I decided (as described by Conover) by calculating the
> 1-alpha quantile and if D was greater than this value, the H_0 is
> rejected. However I dont calculate a P value.  Is this method
> significantly different from the method used in R?

The 1-alpha/2 quantile for the two sided test, I think.
That's equivalent to a decision by p-values.

> Since I get the same value of D in both methods is there any reason to
> prefer one over the other?

No.

Uwe Ligges

> Thanks,
>
> -------------------------------------------------------------------
> Rajarshi Guha <rajarshi at presidency.com> <http://jijo.cjb.net>
> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
> -------------------------------------------------------------------
> After a number of decimal places, nobody gives a damn.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help

```