Re: [R] Question about Kolmogorov-Smirnov Test

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Wed, 26 Nov 2008 14:43:53 +0100

Ricardo Ríos wrote:
> Hi wizards
>
> I have the following code for a Kolmogorov-Smirnov Test:
>
> z<-c(1.6,10.3,3.5,13.5,18.4,7.7,24.3,10.7,8.4,4.9,7.9,12,16.2,6.8,14.7)
> ks.test(z,"pexp",1/10)$statistic
>
> The Kolmogorov-Smirnov statistic is:
>
> D
> 0.293383
>
> However, I have calculated the Kolmogorov-Smirnov statistic with the
> following R code:
>
> z<-c(1.6,10.3,3.5,13.5,18.4,7.7,24.3,10.7,8.4,4.9,7.9,12,16.2,6.8,14.7)
> a<-sort(z)
> d<- pexp(a, rate = 1/10, lower.tail = TRUE, log.p = FALSE)
> w=numeric(length = length(a))
> for(i in 1:length(a)) w[i]=i/15
> max(abs(w-d))
>
> But I have obtained the following result:
>
> [1] 0.2267163
>
> Why these results are not equal?

w is calculated as follows:

w <- (seq(along=a)-1)/length(a)
[ {0, ..., n-1} rather than {1, ..., n} ]

Uwe Ligges

> Thanks in advance
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 26 Nov 2008 - 13:48:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 26 Nov 2008 - 14:00:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive