[Rd] ks.test in ctest package (PR#934)

mh.smith@auckland.ac.nz mh.smith@auckland.ac.nz
Tue, 8 May 2001 06:49:47 +0200 (MET DST)


1.    There is, I believe, some redundant code in the calculation of the
test statistic in ks.test in the package ctest.

 Lines 34-37 of the code read

          x <- y(sort(x), ...) - (0:(n - 1))/n
        STATISTIC <- switch(alternative, two.sided = max(abs(c(x,
           x - 1/n))), greater = max(c(x, x - 1/n)), less = -min(c(x,
            x - 1/n)))


Lines 35-37 could read

        STATISTIC <- switch(alternative, two.sided = max(c(x,1/n - x)),
                        greater = max(x), less = max(1/n - x))

Because

    x > x - 1/n and  1/n - x  > -x,

and thus

max(abs(c(x, x - 1/n))) = max(c(x,1/n - x)),

max(c(x, x - 1/n)) = max(x)

and

-min(c(x, x - 1/n)) = max (1/n - x)

2.    The manual entry should also make it clear that the one-sided
tests are not about theactual cdf in relation to the null hypothsis cdf
Fo, but about the quantiles of the actual distribution in relation to
the quantiles of the null hypothesis cdf.

For example the "greater" test has the STATISTIC, from line 34,

       y(sort(x)) - (0:(n-1))/n

If this is large positive it would contain evidence that the actual cdf
F is less than the null hypothesis Fo. This is the traditional form of
the "less" alternative hypothesis.

    Ha:  F < Fo

is equivalent to the quantiles of the actual distribution being greater
than quantiles of the null hypothesised cdf Fo, consequently the manual
entry should make clear that the one sided alternatives "greater" or
"less" refers to the quantiles and not the cdf's.

3.    Another feature that it would be very useful to add to ks.test
would be the automatic return of  a confidence interval for the actual
cdf F.  Adding a conf.level argument and taking the form of the interval
from the value of the alternative argument would be a relatively simple
task, although it would require .  This would bring the value of the
function into line with the t.test function.


--
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Murray H. Smith,      Senior Lecturer in Engineering Statistics
Engineering Science Department
The University of Auckland
Private Bag 92019
Auckland
New Zealand
Phone: +64 9 373 7599 x4517, Fax: +64 9 373 7468
email: mh.smith@auckland.ac.nz
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._