[S] BUG in BUG fix for ks.gof()

S.D.Byers (byers@stat.washington.edu)
Mon, 6 Apr 1998 22:34:38 -0700 (PDT)


Oooooooooooops. The fix I gave for the suspected bug in ks.gof() does not
take within-sample ties very well (i.e. it is wrong!), hence another
version for ks2() below.

By the way I have no clue what the content of Hollander and Wolfe (1973)
is, I am just trying to fix the function and all that comment is in the
original.

In case you wonder how important the error was, for the situation Enrica
is looking at the result of the test reverses, i.e. using the faulty
version the KS test rejects strongly, the "correct version" fails to
reject at 5%. We checked our new version by finding the ecdfs with ecdf()
(from Hmisc) and looking at them.

SDB

function(x, y, alt.expanded)
{
###
#Calculates value of the KS statistic for two samples
#Implements procedure of Hollander and Wolfe (1973), Nonparameteric
#Statistical Methods, pg. 224-226, using empirical distribution fncs.
#Handles tied observations
#------------------------------------
#Input
#x one sample
#y other sample
#alt.expanded one of "two.sided", "greater", or "less"
######################################################################
nx <- length(x)
ny <- length(y)
z <- sort(unique(c(x, y)))
x.counts <- summary(factor(match(x, z), levels = 1:length(z)))
y.counts <- summary(factor(match(y, z), levels = 1:length(z)))
F.x <- cumsum(x.counts)/nx
F.y <- cumsum(y.counts)/ny
switch(alt.expanded,
less = max(F.y - F.x),
#T-
greater = max(F.x - F.y),
#T+
max(abs(F.x - F.y)) #T
)
}

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news