Skip to content
Prev 307773 / 398503 Next

ks.test not working?

Hello,

First of all, you should say which packages you are using. There is a 
function ks.boot in package Matching and there are functions pgev in 
several packages. For instance, package evd.
Apparently there is nothing wrong with ks.test, you simply are unable to 
call ks.boot. So, write a ks_boot function with the same arguments as 
ks.test plus an extra 'nboots' argument.


ks_boot <- function(x, y, ...,
         alternative = c("two.sided", "less", "greater"),
         exact = NULL, nboots = 1000){
     alt <- match.arg(alternative)
     n <- length(x)
     D <- numeric(nboots)
     p <- numeric(nboots)
     for(i in seq_len(nboots)){
         idx <- sample(n, n, replace = TRUE)
         ks <- ks.test(x[idx], y, ..., alternative = alt, exact = exact)
         D[i] <- ks$statistic
         p[i] <- ks$p.value
     }
     list(D = mean(D), p.value = mean(p), nboots = nboots)
}


Hope this helps,

Rui Barradas
Em 12-10-2012 04:09, Louise.Wilson at csiro.au escreveu: