lily
2008-Jul-06 16:01 UTC
[R] Hi~problem with the two sample test: ks2Test in the package of fbasics
Hi everyone, when I use the two sample Kolmogorov¨CSmirnov ks2Test like this: x=read.table("e:/x.txt") y=rstable(1000,alpha,beta,gamma,delta) I alway get results as follows: Warning messages: 1: In ks.test(x = x, y = y, alternative = "two.sided") : cannot compute correct p-values with ties 2: In ks.test(x = x, y = y, exact = TRUE, alternative = "two.sided") : cannot compute correct p-values with ties 3: In ks.test(x = x, y = y, alternative = "less") : cannot compute correct p-values with ties 4: In ks.test(x = x, y = y, alternative = "greater") : cannot compute correct p-values with ties I know that the one-sample Kolmogorov¨CSmirnov test only applied to continuous distributions, does the two-sample ks test require this? Even if it requires, the stable distribution is continuous. So I also tried this: x=read.table("e:/x.txt"); y=rnorm(1000,mean,sd); ks2Test(x,y); And this: x=read.table("e:/x.txt"); ks.test(x,"norm"); Strangely,I got a total same result! I really want to know whether there are any other sources that could induce this result except for the continuity of distribution? If there are, what are they? Any help will be much appreciated! [[alternative HTML version deleted]]
l y
2008-Jul-07 03:44 UTC
[R] Hi~problem with the two sample test: ks2Test in the package of fbasics
Hi everyone, when I use the two sample Kolmogorov¨CSmirnov ks2Test like this: x=read.table("e:/x.txt") y=rstable(1000,alpha,beta,gamma,delta) I alway get results as follows: Warning messages: 1: In ks.test(x = x, y = y, alternative = "two.sided") : cannot compute correct p-values with ties 2: In ks.test(x = x, y = y, exact = TRUE, alternative = "two.sided") : cannot compute correct p-values with ties 3: In ks.test(x = x, y = y, alternative = "less") : cannot compute correct p-values with ties 4: In ks.test(x = x, y = y, alternative = "greater") : cannot compute correct p-values with ties I know that the one-sample Kolmogorov¨CSmirnov test only applied to continuous distributions, does the two-sample ks test require this? Even if it requires, the stable distribution is continuous. So I also tried this: x=read.table("e:/x.txt"); y=rnorm(1000,mean,sd); ks2Test(x,y); And this: x=read.table("e:/x.txt"); ks.test(x,"norm"); Strangely,I got a total same result! I really want to know whether there are any other sources that could induce this result except for the continuity of distribution? If there are, what are they? Any help will be much appreciated! Lily [[alternative HTML version deleted]]
Ben Bolker
2008-Jul-07 13:54 UTC
[R] Hi~problem with the two sample test: ks2Test in the package of fbasics
l y <pligly <at> gmail.com> writes:> > Hi everyone, when I use the two sample Kolmogorov?CSmirnov ks2Test like this: > x=read.table("e:/x.txt") > y=rstable(1000,alpha,beta,gamma,delta) > > I alway get results as follows: > Warning messages:[snip]> Strangely,I got a total same result! I really want to know whether there are > any other sources that could induce this result except for the continuity > of distribution? If there are, what are they? > Any help will be much appreciated! > > Lily >The problem is that you have ties in your *data* -- nothing to do with the distribution you are testing against. You could try adding a tiny bit of random noise to your data and see if it makes any difference in the answers -- e.g. ks.test(rnorm(length(x),mean=x,sd=0.0001),y) Others may have better ideas. Make sure to look at ?ks.test and read the paragraph about ties carefully ... Ben Bolker