Re: [R] permutational Kolmogorov-Smirnov p-value for paired data

From: Greg Snow <>
Date: Wed 12 Oct 2005 - 04:46:30 EST

Here is one way to do a paired permutation test:

perm1 <- function(x,y){

	rb <- rbinom(length(x),1,0.5)
	xp <- ifelse(rb==1, x, y)
	yp <- ifelse(rb==1, y, x)


my.x <- rnorm(100)
my.y <- my.x + rnorm(100, 0.2, 0.1)

mystat <- ks.test(my.x,my.y)$statistic

out <- replicate(1000, perm1(my.x,my.y) ) hist(out)
mean(out > mystat)

hope this helps,

Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
(801) 408-8111

>>> John Chen <> 10/07/05 06:05AM >>>
Dear List,

I am new to R and find it very powerful. I would like to compute the permutational p-value for paired data using Kolmogorov-Smirnov, but the built-in ks.test does not have this option, unlike the t.test which has a paired=TRUE flag. Has someone written a library or a routine that does this? Alternatively, if someone could show me how to do pair-wise permutations in R, then I can compute the ks statistic for each permutation, that'll work too. Thank you!

John mailing list PLEASE do read the posting guide! mailing list PLEASE do read the posting guide! Received on Wed Oct 12 05:04:09 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:41:12 EST