Bryan Keller
2010-Apr-26 12:22 UTC
[R] Permutation tests using apply function with package coin
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