[R] manova permutations and pair-wise contrasts

Tyler Smith tyler.smith at mail.mcgill.ca
Wed May 30 18:13:34 CEST 2007


I have a function for doing permutation tests for Manovas, written
with the help of folks here on the list. It seems to work ok, and I've
found that there is indeed a significant difference among groups in my
analysis. I want to follow up on this by testing for which pairs of
groups are significantly different. Reasoning that since Wilks Lambda
is a generalization of the Hotelling T test, it should be appropriate
for testing difference between two groups as well as between many
groups, I used the same function. 

This appears to work, with one exception. For one pair of groups the
residuals have rank 14 < 15. Reading through the archives I see that
this problem comes up with permutation tests on occassion. My question
is, does this problem indicate a mistaken assumption or faulty code on
my part, and is there anyway to address it, either with a different
approach or a change to my function?

The actual function I use is:

wilks.perm <- function(data.mat, cat.vect, n=999){
  res.vect <- numeric(n+1)

  for (i in 1:n){
    wilks <- summary(manova(data.mat ~ sample(cat.vect)),
    res.vect[i] <- wilks

  res.vect[n+1] <- obs <-
    summary(manova(data.mat~cat.vect), test="Wilks")$stats[1,2]

  return(sum(res.vect <= res.vect[n+1])/(n+1))




More information about the R-help mailing list