Skip to content
Prev 18281 / 398503 Next

ks.test - continuous vs discrete

"obvious" depends on the problem you want to test: KS tests the hypothesis

H_0: F(z) = G(z) for all z vs. H_1: F(z) != G(z) for at least one z 

ks.test assumes that both F and G are continuous variables. However, if
you want to test

H_0: F(z) = G(z)  vs. H_1: F(z) = G(z - delta); delta != 0

as "test for differences" indicates, the Wilcoxon rank sum test is
"obvious". Or, more general, if your hypothesis is "exchangeability", a
permutation test can be used.
or maybe the underlying distribution is discrete? 

Anyway: ks.test and wilcox.test in ctest assume data from continuous
distributions and the normal approximation is used if ties occur. 

For the Wilcoxon and permutation test, the conditional distribution (that
is: conditional on the ties) can be computed using the exactRankTests
package.
For your example: 

R> library(exactRankTests)
R> wilcox.exact(B, A)

        Exact Wilcoxon rank sum test

data:  B and A 
W = 36.5, p-value = 0.02039
alternative hypothesis: true mu is not equal to 0 


R> perm.test(B, A)

        2-sample Permutation Test

data:  B and A 
T = 1118, p-value = 0.01864
alternative hypothesis: true mu is not equal to 0 

Torsten
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._