BCompare groups · Guide test 172
PERMDISP
Tests group dispersion differences through distances to group centers in a distance based space.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- PERMDISP (homogeneity of multivariate dispersions) — Do groups differ in how spread out their rows are, judged by a dissimilarity?
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 · PERMDISP
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, gray spokes each row's distance to its centroid.
If H₀ were true
- The reference: how F varies across samples when H₀ is true, F over permuted residuals (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 = .560).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- centroid of group i
- distance of a row to its own centroid
- one-way ANOVA of those distances, calibrated by permuting residuals
The verdict
F = 4.82, p = .560
p > α = .050: compatible with H₀
A multivariate Levene test. Run it alongside PERMANOVA: a PERMANOVA rejection with a PERMDISP rejection may be about spread, not location.
- Statistic
- 4.824
- p-value
- 0.5600
PERMDISP on 3 groups of 15 rows on two variables: F = 4.82, p = .560. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: groups have equal average distance to their multivariate centers.
Assumptions
Independent units; valid permutation scheme; a chosen distance and center (centroid or spatial median).
Formula
Parameters and notation
Distances are usually computed in principal-coordinate space; non-Euclidean negative eigenvalues require the implementation’s correction.
Structure of the method
Embed the distance matrix in principal-coordinate space, compute each observation's distance to its group centroid or spatial median, and test differences in average distances. The documented residual-permutation procedure operates on the resulting dispersion model. This targets spread around fitted centers, not equality of the centers themselves.
Estimated and nuisance parameters
Group centers, principal-coordinate scores/eigenvalues, group mean distances, and residual variation are estimated. The location choice is not a learned hyperparameter to optimize for rejection; it defines which dispersion summary is being compared.
Settings and design choices
Specify centroid versus spatial median, small-sample bias adjustment, distance transformation/additive correction, permutations, and pairwise follow-up rules. The documented vegan default is the spatial median. Negative principal-coordinate eigenvalues require the selected implementation's treatment rather than silently discarding problematic dimensions.
Fitting and adaptation
Fit centers and the dispersion model according to the exact algorithm, then apply its supported residual-permutation calibration. Refit when group composition or preprocessing changes. If distances use learned representations, preserve a valid independent training/calibration boundary. Pairwise comparisons after an omnibus result still require their own multiplicity plan.
Sensitivity and robustness
Estimated distances can be biased for small groups, with unequal sizes especially consequential. Outliers, non-Euclidean geometry, and near-zero within-group dispersion affect the test. Dependence must be represented in exchange restrictions. A nonsignificant dispersion test does not prove PERMANOVA's location interpretation; evaluate effect sizes and precision rather than relying only on a threshold.
How to use and calibrate
Use the documented residual permutation procedure or approximate ANOVA, including bias adjustment if selected.
Example application
Check whether habitat groups differ in community dispersion.
Interpretation and pitfalls
Watch out
This tests spread around centers, not equality of centroids. Small unequal groups can bias estimated distances.
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::permutest(vegan::betadisper(dist(Z),g),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::permutest(vegan::betadisper(dist(Z),g),permutations=999))
Output
Permutation test for homogeneity of multivariate dispersions
Permutation: free
Number of permutations: 999
Response: Distances
Df Sum Sq Mean Sq F N.Perm Pr(>F)
Groups 1 1.042 1.04236 2.3772 999 0.122
Residuals 88 38.587 0.43849Sources
- vegandevs.github.io/vegan/reference/betadisper.htmlvegandevs.github.io
- betadispervegandevs.github.io
- betadispersearch.r-project.org
- permutestsearch.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 172, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT172.