Re: [S] BUG in ks.gof() ?

S.D.Byers (byers@stat.washington.edu)
Wed, 8 Apr 1998 08:49:24 -0700 (PDT)


Andreas Christmann tested out the possible BUG in ks.gof() I mailed a
while ago, in S+ 4.0 for PC apprently it does NOT exist, presumably having
been fixed by MathSoft (?). The S+4.0 correct version of ks2() is below,
for those of you in 3.4 who might wish to use it (it is almost the same as
my fix).

SDB

ks2 <- 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)))
ma.x <- match(x, z)
ma.y <- match(y, z)
F.x <- cumsum(tabulate(ma.x, length(z)))/nx
F.y <- cumsum(tabulate(ma.y, length(z)))/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