[R] Question about Kolmogorov-Smirnov Test

Ricardo Ríos ricardo.rios.sv at gmail.com
Wed Nov 26 04:08:53 CET 2008


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?

Thanks in advance

-- 
http://ricardorios.wordpress.com/



More information about the R-help mailing list