BCompare groups · Guide test 170
PERMANOVA
Uses permutations of a distance based pseudo F statistic to test multivariate group or model effects.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- PERMANOVA (permutational MANOVA) — Do groups differ in their multivariate profile, judged by a dissimilarity between rows?
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · PERMANOVA
Above 1 the later groups are more spread out (unequal covariance matrices).
Your data
Simulated with known truth3 groups on two measurements; crosses mark the group means.
If H₀ were true
- The reference: how F varies across samples when H₀ is true, pseudo-F over relabelings (permutation null: 199 relabelings of these data (seed 20261107)).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .220).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- Euclidean distance between rows i and j
- among-group sum of squares
The verdict
F = 1.46, p = .220
p > α = .050: compatible with H₀
PERMANOVA also reacts to unequal spread between groups, especially with unequal sizes: check PERMDISP before reading a rejection as different centroids.
- Statistic
- 1.456
- p-value
- 0.2200
PERMANOVA on 3 groups of 12 rows on two variables: F = 1.46, p = .220. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: no group/design effect in the chosen distance representation; identical distributions justify unrestricted label permutation.
Assumptions
Independent exchangeable units or an explicitly restricted permutation design; a scientifically suitable dissimilarity.
Formula
Parameters and notation
Displayed one-way PERMANOVA. Regression versions partition a centered distance matrix by model projections and specify sequential versus marginal terms.
Structure of the method
Convert dissimilarities into centered distance geometry, project this representation onto a design matrix, and partition explained and residual sums of squares. The one-way pseudo-F is a special case. The reference distribution comes from the specified permutation mechanism, not an automatic parametric F distribution.
Estimated and nuisance parameters
Regression projections and fitted distance-space effects depend on the design; group centroids are implicit in the Euclidean one-way case. Partial or sequential explained fractions summarize fitted variation. The distance definition and permutation structure are design choices, not estimated regression coefficients.
Settings and design choices
Prespecify distance, transformations, sequential versus marginal term tests, model order, interactions, blocks/strata, and permutation count. New implementation variants that explicitly address unequal dispersion must be named; they do not retroactively change the ordinary pseudo-F test.
Fitting and adaptation
Fit the scientific design and recalibrate with exchanges valid under that design, including an appropriate residual-permutation procedure for nuisance covariates where required. If response features or predictors were selected for significance, repeat selection under calibration or evaluate independently. Updating the model is refitting a distance regression, not neural fine-tuning.
Sensitivity and robustness
Unequal within-group dispersion can confound centroid interpretations, especially in unbalanced samples. Check influential distances, negative eigenvalues from non-Euclidean measures, sparse cells, and permutation availability. Report dispersion diagnostics and effect estimates with p-values; a significant overall test does not identify every pairwise difference.
How to use and calibrate
Use a design-correct permutation distribution, not an ordinary F table.
Example application
Compare ecological community compositions across habitats.
Interpretation and pitfalls
Watch out
Unequal dispersion can produce rejection, especially in unbalanced designs. Inspect dispersion and interpret centroid claims carefully.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Euclidean distance, independent groups, 999 unrestricted permutations. Clustered or repeated designs require restricted permutations; location and dispersion can affect different procedures.
Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: vegan
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
X<-matrix(rnorm(120),ncol=3);Y<-matrix(rnorm(150,mean=.3),ncol=3)
Z<-rbind(X,Y);g<-factor(rep(1:2,c(nrow(X),nrow(Y))))
print(vegan::adonis2(Z~g,method="euclidean",permutations=999))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Validated — Executed successfully in the validation environment · needs vegan
set.seed(2026)
X<-matrix(rnorm(120),ncol=3);Y<-matrix(rnorm(150,mean=.3),ncol=3)
Z<-rbind(X,Y);g<-factor(rep(1:2,c(nrow(X),nrow(Y))))
print(vegan::adonis2(Z~g,method="euclidean",permutations=999))
Output
Permutation test for adonis under reduced model
Terms added sequentially (first to last)
Permutation: free
Number of permutations: 999
vegan::adonis2(formula = Z ~ g, permutations = 999, method = "euclidean")
Df SumOfSqs R2 F Pr(>F)
g 1 20.304 0.07598 7.2363 0.001 ***
Residual 88 246.918 0.92402
Total 89 267.222 1.00000
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Sources
- vegandevs.github.io/vegan/reference/adonis.htmlvegandevs.github.io
- adonisvegandevs.github.io
- adonis2search.r-project.org
- Statistics guide v4 (historical):
- Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 170, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT170.