hypeR icon indicating copy to clipboard operation
hypeR copied to clipboard

.kstest needs to match ks.test (modulo the sign)

Open tetomonti opened this issue 2 years ago • 0 comments

I realized that .kstest, as it is now implemented, does not match ks.test's behavior when alternative != "two.sided". In particular, the score in ks.test is defined as follows:

STATISTIC <- switch(alternative, two.sided = max(abs(z)), 
        greater = max(z), less = -min(z))

Thus, in .kstest, score should be computed as follows:

score <- if (absolute) max(z)-min(z) else switch(alternative, 
         two.sided = z[which.max(abs(z))],
         greater = max(z), 
         less = min(z))

Also, the command

results <- suppressWarnings(ks.test(1:n.x, y, alternative="less"))

should be replaced by

results <- suppressWarnings(ks.test(y, 1:n.x, alternative="greater"))

tetomonti avatar May 16 '22 12:05 tetomonti