[R] calculation of the p value in ks.test()

Rajarshi Guha rajarshi at presidency.com
Tue Sep 16 23:58:53 CEST 2003


Hi,
  I'm working with the ks.test() function and I have also implemented
the test using Conover as the reference. My D value matches that
produced by R. However to calculate the p value I am using the code
described in Numerical Recipes in C++ (2nd Ed.) pg 631.

The p value produced by the NRC code is generally larger than that
produced by R by a factor of 10. Currently I am not in a position to
download the R source and look at it - lack of space :(

has anybody used the NRC code? The text mentions that it calculates the
sum

Q(L) = 2 \sum^{-\infty}_{j=1} (-1)^(j-1) \exp^{-2 j^2 L^2}

and the value of L is given by

[ sqrt(n) + 0.12 + 0.11 / sqrt(n) ] * D

where n = n1*n2/(n1+n2) .. n1, n2 are lengths of the vectors
and D is the calculated statistic.

Is this the same definition as used in R?

Thanks,

-------------------------------------------------------------------
Rajarshi Guha <rajarshi at presidency.com> <http://jijo.cjb.net>
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
-------------------------------------------------------------------
All great ideas are controversial, or have been at one time.




More information about the R-help mailing list