[R] Kolmogorov Smirnov Distribution

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Nov 17 14:15:13 CET 2006


On Fri, 17 Nov 2006, jacinthe at gmx.de wrote:

> Hi,
>
> i need to calculate the p-value given the kolmogorv smirnov test 
> statistic (two sided). When I look at the function ks.test I found the 
> following function which calls C code:
>
> pkstwo <- function(x, tol = 1e-06) {
>    if (is.numeric(x))
>        x <- as.vector(x)
>    else stop("Argument x must be numeric")
>    p <- rep(0, length(x))
>    p[is.na(x)] <- NA
>    IND <- which(!is.na(x) & (x > 0))
>    if (length(IND) > 0) {
>        p[IND] <- .C("pkstwo", as.integer(length(x)), p = as.double(x[IND]),
>            as.double(tol), PACKAGE = "ctest")$p
>    }
>    return(p)
> }

Not from a version of R from at least the last 3 years!

> Extracting and using this function, I get the following error message:
>
> Error in .C("pkstwo", as.integer(length(x)), p = as.double(x[IND]), as.double(tol),  :
>        C entry point "pkstwo" not in DLL for package "ctest"

> Any suggestions (perhaps a small example) how to calculate the p-value 
> for the KS-statistic (without using ks.test()!!!). Help is welcome.

Use pkstwo from a current version of R, which has PACKAGE = "stats".

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list