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@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.

Reply via email to