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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ks.test in ctest package (PR#934)
2 messages · mh.smith@auckland.ac.nz, Kurt Hornik
5 days later
mh smith writes:
1. There is, I believe, some redundant code in the calculation of the test statistic in ks.test in the package ctest.
Thanks, fixed.
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.
...
THanks for catching this bug. This should really give the usual behavior that e.g. `alternative = "less"' means H_0: F >= F_0 for all points vs H_a: F(t) < F_0(t) for some t. Fixed now.
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.
I am not sure whether we want to do this in the simple htest framework. Attempting to print a confidence interval given by two functions rather than two values will be confusing. I'd much rather have users do confint(ecdf(x), conf.level = 0.95) where a generic confint as in MASS with a method for objects of class "ecdf" as in stepfun. [The ``classical'' tests conceptually are really about a single parameter only. Should this be changed? One could argue that if a hypothesis about the underlying distribution function is tested ...] -k -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._