[R] Permutation tests using apply function with package coin

Bryan Keller bskeller at wisc.edu
Mon Apr 26 14:22:33 CEST 2010


I am using "apply" to run exact permutation t-tests by columns
using the coin package.  For example:

library(coin)
dat <- matrix(rnorm(7*35),7,35)
fun <- function(x) {
	pvalue(	independence_test(x~f, 
			data=data.frame(x, f=factor(c(rep("a",4),rep("b",3)))), 
			distribution = "exact"))
		}
p.vals <- apply(dat, 2, fun)

Some small-scale comparisons with the perm package show 
that coin does the actual permutation tests much faster
than perm but when I apply them both over the same matrix
coin ends up taking longer.  My guess is that turning 
each column into a data frame is what slows coin down.
Any ideas on how to tune this up would be most appreciated.

Bryan
 
---------------
Bryan Keller, Doctoral Student/Project Assistant
Educational Psychology - Quantitative Methods
The University of Wisconsin - Madison



More information about the R-help mailing list