From the PRIMER manual (p. 28 about Monte Carlo permutations; http://updates.primer-e.com/primer7/manuals/PERMANOVA+_manual.pdf), the number of unique permutations for a PERMANOVA with $a$ groups and $n$ replicates per group is: $$ (an)![a!(n!)^a]. $$ However, what is the calculation if the study design is unbalanced? For example, one group with $4$ individuals, another with $5$, another with $6$? Is there a way to calculate the number of unique permutations with adonis2?

Thank you for pointing numPerms(). However, I am getting an incorrect answer, even with simpler examples.

# Create 2 groups of 5. 
myVec = c(rep("A",5), rep("B", 5))

# Define the permutation scheme. 
hh = how(within = Within(type = "free"),
          blocks = as.factor(myVec))

# Calculate number of permutations
numPerms(nobs(myVec), hh)

However, 2 groups of 5 should have 945 unique permutations, but this returns 14400. What did I do wrong?

  • 1
    $\begingroup$ This is a special case of the general answer I gave at stats.stackexchange.com/a/415878/919. $\endgroup$
    – whuber
    Jan 5, 2023 at 21:25
  • $\begingroup$ Thank you for pointing me in the right direction, but I'm not sure if I know how to solve it for this case. Following your equations, what would the values be for k? $\endgroup$
    – planktonQ
    Jan 5, 2023 at 22:44

1 Answer 1


Function permute::numPerms calculates the number of permutations for your current model. The permutations in vegan::adonis2 are based on this very same permute package, and if you have specific problems with permutations, you should consult the permute package. Use numPerms() and read its help page.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.