Skip to content

PERMDISP, ANOSIM and MRPP

Test spread with PERMDISP, use ranks with ANOSIM and within-group distance with MRPP, and know why these tests can answer differently on the same data.

Advanced ~12 min10 steps

What runs in CodeSplash

You will be able to

  • Use PERMDISP to test for differences in multivariate spread
  • Compute ANOSIM's R and MRPP's A from their parts
  • Explain which group-difference question each test answers

Read first

01

Three tests, three questions

Read

All three start from the same dissimilarity matrix and all three shuffle labels, but they don't ask the same thing.

TestThe question
PERMDISPPERMDISPTests whether groups differ in spread — the mean distance of their rows to the group's spatial median or centroid.Are some groups more spread out than others?
ANOSIMANOSIMCompares ranked dissimilarities between groups with those within; R from −1 to 1, near 0 for no separation.Are between-group ranks larger than within-group ranks?
MRPPMRPPAsks whether rows within groups are closer than random sets of the same sizes; A = 1 − δ/E(δ).Are rows closer within groups than chance would give?

PERMANOVA and these three may disagree on one dataset. That usually tells you something real about it.

02

PERMDISP: spread in any distance

Read

Find each group's center, take each row's distance to it, and run an ANOVA on those distances. It is the Levene test idea, carried over to many dimensions.

On the simulated two-group study, with the spatial medianSpatial medianThe point that minimizes the sum of distances to all rows — a robust multivariate center. as center, F = 2.38, permutation p = 0.10. With the centroid, F = 2.57, p = 0.085.

The spatial median is less affected by outlying rows, so it's the default.

03

Small groups look tighter

Predict

Predict first

Each group's center is estimated from its own rows. If a group has only four rows, how do its rows look when measured against that center?

Tighter than it truly isMore spread out than it truly isNo bias at all
Reveal

Tighter. Each row helped choose the center, so it sits closer to it than to the true center. Small-group bias adjustment corrects this. On the meadow data with four groups of unequal size, the adjusted test gives F = 1.57, p = 0.27.

04

ANOSIM: ranks

Read

ANOSIM ranks all pairwise dissimilarities, then compares mean ranks:

R=rˉB−rˉWM/2,M=N(N−1)/2R = \frac{\bar r_B - \bar r_W}{M/2}, \qquad M = N(N-1)/2

RR near 0 means between-group pairs are no further apart than within-group pairs. RR near 1 means all the closest pairs are within groups.

For the meadow plots by management, rˉB\bar r_B = 101.0 and rˉW\bar r_W = 76.5, so RR = 0.26, p = 0.02.

05

MRPP: within-group distance

In the app

MRPP takes δ\delta, the weighted mean of within-group dissimilarities, and compares it with its expected value when labels are shuffled. The chance-corrected effect is A=1−δ/E(δ)A = 1 - \delta / E(\delta).

MRPP: multi-response permutation procedureRecorded · Python and R agreeRecorded 2026-11-17 · 12 values compared
R

MRPP (Bray–Curtis), δ = 0.57, A = 0.110, p = .015

δ
0.5746
E(δ)
0.6456
A
0.1100
p
.015

Effect size

  • Chance-corrected within-group agreement A 0.1100

Plots

Principal coordinates of the Bray–Curtis dissimilarities by ManagementDo the groups separate in the dissimilarity space, and do they differ in where they sit or in how spread out they are?
View data
ManagementPCoA 1 (37.4%)PCoA 2 (22.3%)
SF−0.3547−0.2567
BF−0.2946−0.1861
SF−0.0728−0.2909
SF−0.0693−0.2642
HF−0.30710.0303
HF−0.25300.0942
HF−0.3096−0.0191
HF0.1773−0.1701
HF0.0174−0.2467
BF−0.31120.0546
BF−0.20230.1411
SF0.1955−0.1259
SF0.1799−0.2152
NM0.43010.0861
NM0.48770.1150
SF0.5112−0.1109
NM−0.19480.4965
NM−0.13340.2411
NM−0.00540.4691
NM0.50920.1575

Assumptions

  • Similar spread across groups — MRPP compares within-group distances, so a tight group can drive a significant result on its own; see the class δ table.
  • Exchangeable rows — Labels were permuted freely; give blocks or sites as strata so permutations respect the design.

Mean within-group dissimilarity

Managementnδ (mean dissimilarity)
BF30.4160
HF50.4418
NM60.6882
SF60.5813
  • Bray–Curtis dissimilarity of the variables; group weights n_g(n_g − 1) / Σ n_g(n_g − 1); lower-tail p from 199 label permutations (seed 42).
The exact R script · R R version 4.5.1 (2025-06-13)
# MRPP (multi-response permutation procedure)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method multivariate.mrpp 1.0.1 · spec 2f1b1a841c13aa88
# Dataset: mv_dune (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/mv_dune.parquet", col_select = c("Achimill", "Agrostol", "Airaprae", "Alopgeni", "Anthodor", "Bellpere", "Bromhord", "Chenalbu", "Cirsarve", "Comapalu", "Eleopalu", "Elymrepe", "Empenigr", "Hyporadi", "Juncarti", "Juncbufo", "Lolipere", "Planlanc", "Poaprat", "Poatriv", "Ranuflam", "Rumeacet", "Sagiproc", "Salirepe", "Scorautu", "Trifprat", "Trifrepe", "Vicilath", "Bracruta", "Callcusp", "Management")))
n_input <- nrow(df)
df[["Management"]] <- factor(df[["Management"]], levels = c("BF", "HF", "NM", "SF"))  # stored level order
df <- df[stats::complete.cases(df[c("Achimill", "Agrostol", "Airaprae", "Alopgeni", "Anthodor", "Bellpere", "Bromhord", "Chenalbu", "Cirsarve", "Comapalu", "Eleopalu", "Elymrepe", "Empenigr", "Hyporadi", "Juncarti", "Juncbufo", "Lolipere", "Planlanc", "Poaprat", "Poatriv", "Ranuflam", "Rumeacet", "Sagiproc", "Salirepe", "Scorautu", "Trifprat", "Trifrepe", "Vicilath", "Bracruta", "Callcusp", "Management")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("Achimill", "Agrostol", "Airaprae", "Alopgeni", "Anthodor", "Bellpere", "Bromhord", "Chenalbu", "Cirsarve", "Comapalu", "Eleopalu", "Elymrepe", "Empenigr", "Hyporadi", "Juncarti", "Juncbufo", "Lolipere", "Planlanc", "Poaprat", "Poatriv", "Ranuflam", "Rumeacet", "Sagiproc", "Salirepe", "Scorautu", "Trifprat", "Trifrepe", "Vicilath", "Bracruta", "Callcusp", "Management"))  # infinite values stop the run (registry/errors.yaml)

# %% Distances
# The dissimilarity between every pair of rows after the chosen transform (codesplashr cs_mvd_*); all
# permutations come from the shared Wichmann-Hill stream, so Python and R draw the same relabellings.
variables <- c("Achimill", "Agrostol", "Airaprae", "Alopgeni", "Anthodor", "Bellpere", "Bromhord", "Chenalbu", "Cirsarve", "Comapalu", "Eleopalu", "Elymrepe", "Empenigr", "Hyporadi", "Juncarti", "Juncbufo", "Lolipere", "Planlanc", "Poaprat", "Poatriv", "Ranuflam", "Rumeacet", "Sagiproc", "Salirepe", "Scorautu", "Trifprat", "Trifrepe", "Vicilath", "Bracruta", "Callcusp")
transform_kind <- "none"  # none | standardize | range | hellinger | log1p
metric <- "bray"  # euclidean | manhattan | bray | jaccard | gower
seed <- 42
n_perm <- as.integer(199)
DIST_LABEL <- c(euclidean = "Euclidean", manhattan = "Manhattan", bray = "Bray–Curtis", jaccard = "Jaccard", gower = "Gower")
TRANSFORM_LABEL <- c(none = "", standardize = "standardized ", range = "range-scaled ", hellinger = "Hellinger-transformed ", log1p = "log(1 + x) ")
Y <- as.matrix(df[variables])
storage.mode(Y) <- "double"
n <- nrow(Y)
dims <- length(variables)
if (n > 5000) stop(sprintf("Distance-based tests use an n × n matrix; %d rows is too many (at most 5000). Filter or sample the data first.", n))
D <- cs_mvd_distance(cs_mvd_transform(Y, transform_kind), metric)
dist_text <- sprintf("%s dissimilarity of the %svariables", DIST_LABEL[[metric]], TRANSFORM_LABEL[[transform_kind]])
g <- "Management"
levels_g <- levels(df[[g]])
codes <- as.integer(df[[g]]) - 1L
k <- length(levels_g)
if (k < 2) cs_error("CS_E_TOO_FEW_GROUPS", column = g, min = 2, k = k)
group_n <- tabulate(codes + 1L, nbins = k)
strata_col <- NULL
strata <- NULL

# %% Test
# MRPP (Mielke, Berry & Johnson 1976): delta = weighted mean of the within-group mean dissimilarities,
# A = 1 - delta / E(delta) with E(delta) the mean of all dissimilarities; small delta is evidence (lower tail).
weighting <- "pairs"  # n | n_minus_1 | pairs
alpha <- 0.05
res <- cs_mvd_mrpp(D, codes, k, weighting, n_perm, seed, strata)
delta <- res$delta
p <- res$p
a <- res$a

# %% Assumptions
assumptions <- list(
  list(key = "dispersion", label = "Similar spread across groups", status = "info",
       detail = "MRPP compares within-group distances, so a tight group can drive a significant result on its own; see the class δ table."),
  list(key = "exchangeable", label = "Exchangeable rows", status = "info",
       detail = if (!is.null(strata_col)) paste0("Labels were permuted within ", strata_col, ".") else
         "Labels were permuted freely; give blocks or sites as strata so permutations respect the design.")
)

# %% Result
summary <- paste0(sprintf("MRPP on the %s: the rows of each group of %s are ", dist_text, g),
                  if (p < alpha) "more alike than expected by chance" else "not more alike than expected by chance",
                  sprintf(" (δ = %s vs E(δ) = %s, A = %.3f, %s, %d permutations).", format(signif(delta, 4)), format(signif(res$expected_delta, 4)), a, cs_fmt_p(p), n_perm))
values <- list(delta = delta, expected_delta = res$expected_delta, a = a, p = p, k = k, n = n, n_perm = n_perm)
for (i in seq_len(k)) values[[sprintf("class_delta[%s]", levels_g[i])]] <- res$class_delta[i]
values$missing_share <- if (n_input > 0) n_dropped / n_input else 0
WEIGHT_TEXT <- c(n = "n_g / N", n_minus_1 = "(n_g − 1) / (N − k)", pairs = "n_g(n_g − 1) / Σ n_g(n_g − 1)")
pc <- cs_mvd_pcoa(D)
V <- pc$vectors
ex <- pc$explained
ax1 <- if (ncol(V) > 0) V[, 1] else rep(0, n)
ax2 <- if (ncol(V) > 1) V[, 2] else rep(0, n)
cs_publish(list(
  method = "multivariate.mrpp",
  methodVersion = "1.0.1",
  title = "MRPP: multi-response permutation procedure",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = n,
  summary = summary,
  apa = sprintf("MRPP (%s), δ = %s, A = %.3f, %s", DIST_LABEL[[metric]], cs_fmt_num(delta), a, cs_fmt_p(p)),
  statistics = list(list(key = "delta", label = "δ", value = delta), list(key = "expected_delta", label = "E(δ)", value = res$expected_delta),
                    list(key = "a", label = "A", value = a), list(key = "p", label = "p", value = p, format = "p")),
  tables = list(list(key = "classes", title = "Mean within-group dissimilarity",
    columns = list(list(key = "group", label = g, type = "string"), list(key = "n", label = "n", type = "integer"),
                   list(key = "delta", label = "δ (mean dissimilarity)", type = "number")),
    rows = data.frame(group = levels_g, n = as.integer(group_n), delta = res$class_delta))),
  effectSizes = list(list(key = "a", label = "Chance-corrected within-group agreement A", value = a,
                          method = "1 − δ / E(δ); 0 = no more alike than chance, 1 = identical within groups")),
  assumptions = assumptions,
  warnings = warnings,
  notes = list(paste0(sprintf("%s; group weights %s; lower-tail p from %d label permutations (seed %d).", dist_text, WEIGHT_TEXT[[weighting]], n_perm, as.integer(seed)),
                      if (!is.null(strata_col)) sprintf(" Permutations were restricted within %s.", strata_col) else "")),
  values = values,
  charts = list(cs_chart("ordination", "pcoa-centroids", sprintf("Principal coordinates of the %s dissimilarities by %s", DIST_LABEL[[metric]], g), list(
    x = cs_col(if (ncol(V) > 0) sprintf("PCoA 1 (%.1f%%)", 100 * ex[1]) else "PCoA 1", ax1),
    y = cs_col(if (ncol(V) > 1) sprintf("PCoA 2 (%.1f%%)", 100 * ex[2]) else "PCoA 2", ax2),
    group = cs_col(g, as.character(df[[g]]), levels = levels_g)), controls = list(center = "centroid", spokes = FALSE, hulls = TRUE)))
))
Python

MRPP (Bray–Curtis), δ = 0.57, A = 0.110, p = .015

δ
0.5746
E(δ)
0.6456
A
0.1100
p
.015

Effect size

  • Chance-corrected within-group agreement A 0.1100

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Similar spread across groups — MRPP compares within-group distances, so a tight group can drive a significant result on its own; see the class δ table.
  • Exchangeable rows — Labels were permuted freely; give blocks or sites as strata so permutations respect the design.

Mean within-group dissimilarity

Managementnδ (mean dissimilarity)
BF30.4160
HF50.4418
NM60.6882
SF60.5813
  • Bray–Curtis dissimilarity of the variables; group weights n_g(n_g − 1) / Σ n_g(n_g − 1); lower-tail p from 199 label permutations (seed 42).
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# MRPP (multi-response permutation procedure)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method multivariate.mrpp 1.0.1 · spec 2f1b1a841c13aa88
# Dataset: mv_dune (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.stats import mvdist

# %% Data
df = pd.read_parquet("tests/parity/fixtures/mv_dune.parquet", columns=["Achimill", "Agrostol", "Airaprae", "Alopgeni", "Anthodor", "Bellpere", "Bromhord", "Chenalbu", "Cirsarve", "Comapalu", "Eleopalu", "Elymrepe", "Empenigr", "Hyporadi", "Juncarti", "Juncbufo", "Lolipere", "Planlanc", "Poaprat", "Poatriv", "Ranuflam", "Rumeacet", "Sagiproc", "Salirepe", "Scorautu", "Trifprat", "Trifrepe", "Vicilath", "Bracruta", "Callcusp", "Management"])
n_input = len(df)
df["Management"] = pd.Categorical(df["Management"], categories=["BF", "HF", "NM", "SF"])  # stored level order
df = df.dropna(subset=["Achimill", "Agrostol", "Airaprae", "Alopgeni", "Anthodor", "Bellpere", "Bromhord", "Chenalbu", "Cirsarve", "Comapalu", "Eleopalu", "Elymrepe", "Empenigr", "Hyporadi", "Juncarti", "Juncbufo", "Lolipere", "Planlanc", "Poaprat", "Poatriv", "Ranuflam", "Rumeacet", "Sagiproc", "Salirepe", "Scorautu", "Trifprat", "Trifrepe", "Vicilath", "Bracruta", "Callcusp", "Management"])  # listwise deletion over the analysis columns
df["Management"] = df["Management"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["Achimill", "Agrostol", "Airaprae", "Alopgeni", "Anthodor", "Bellpere", "Bromhord", "Chenalbu", "Cirsarve", "Comapalu", "Eleopalu", "Elymrepe", "Empenigr", "Hyporadi", "Juncarti", "Juncbufo", "Lolipere", "Planlanc", "Poaprat", "Poatriv", "Ranuflam", "Rumeacet", "Sagiproc", "Salirepe", "Scorautu", "Trifprat", "Trifrepe", "Vicilath", "Bracruta", "Callcusp", "Management"])  # infinite values stop the run (registry/errors.yaml)

# %% Distances
# The dissimilarity between every pair of rows after the chosen transform (codesplash.stats.mvdist); all
# permutations come from the shared Wichmann–Hill stream, so Python and R draw the same relabellings.
variables = ["Achimill", "Agrostol", "Airaprae", "Alopgeni", "Anthodor", "Bellpere", "Bromhord", "Chenalbu", "Cirsarve", "Comapalu", "Eleopalu", "Elymrepe", "Empenigr", "Hyporadi", "Juncarti", "Juncbufo", "Lolipere", "Planlanc", "Poaprat", "Poatriv", "Ranuflam", "Rumeacet", "Sagiproc", "Salirepe", "Scorautu", "Trifprat", "Trifrepe", "Vicilath", "Bracruta", "Callcusp"]
transform_kind = "none"  # none | standardize | range | hellinger | log1p
metric = "bray"  # euclidean | manhattan | bray | jaccard | gower
seed = 42
n_perm = int(199)
DIST_LABEL = {"euclidean": "Euclidean", "manhattan": "Manhattan", "bray": "Bray–Curtis", "jaccard": "Jaccard", "gower": "Gower"}
TRANSFORM_LABEL = {"none": "", "standardize": "standardized ", "range": "range-scaled ", "hellinger": "Hellinger-transformed ", "log1p": "log(1 + x) "}
Y = df[variables].to_numpy(dtype=float)
n = int(Y.shape[0])
dims = len(variables)
if n > 5000:
    raise ValueError(f"Distance-based tests use an n × n matrix; {n} rows is too many (at most 5000). Filter or sample the data first.")
D = mvdist.distance(mvdist.transform(Y, transform_kind), metric)
dist_text = f"{DIST_LABEL[metric]} dissimilarity of the {TRANSFORM_LABEL[transform_kind]}variables"
g = "Management"
levels = [str(lv) for lv in df[g].cat.categories]
codes = df[g].cat.codes.to_numpy().astype(int)
k = len(levels)
if k < 2:
    cs.cs_error("CS_E_TOO_FEW_GROUPS", column=g, min=2, k=k)
group_n = np.bincount(codes, minlength=k)
strata_col = None
strata = None

# %% Test
# MRPP (Mielke, Berry & Johnson 1976): δ = weighted mean of the within-group mean dissimilarities,
# A = 1 − δ / E(δ) with E(δ) the mean of all dissimilarities; small δ is evidence, so p is the lower tail.
weighting = "pairs"  # n | n_minus_1 | pairs
alpha = 0.05
res = mvdist.mrpp(D, codes, k, weighting, n_perm, seed, strata)
delta, p, a = res["delta"], res["p"], res["a"]

# %% Assumptions
assumptions = [
    {"key": "dispersion", "label": "Similar spread across groups", "status": "info",
     "detail": "MRPP compares within-group distances, so a tight group can drive a significant result on its own; see the class δ table."},
    {"key": "exchangeable", "label": "Exchangeable rows", "status": "info",
     "detail": ("Labels were permuted within " + strata_col + "." if strata_col else
                "Labels were permuted freely; give blocks or sites as strata so permutations respect the design.")},
]

# %% Result
summary = (f"MRPP on the {dist_text}: the rows of each group of {g} are " +
           ("more alike than expected by chance" if p < alpha else "not more alike than expected by chance")
           + f" (δ = {delta:.4g} vs E(δ) = {res['expected_delta']:.4g}, A = {a:.3f}, {cs.fmt_p(p)}, {n_perm} permutations).")
values = {"delta": delta, "expected_delta": res["expected_delta"], "a": a, "p": p, "k": k, "n": n, "n_perm": n_perm}
for lv, cd in zip(levels, res["class_delta"]):
    values[f"class_delta[{lv}]"] = float(cd)
values["missing_share"] = n_dropped / n_input if n_input else 0.0
WEIGHT_TEXT = {"n": "n_g / N", "n_minus_1": "(n_g − 1) / (N − k)", "pairs": "n_g(n_g − 1) / Σ n_g(n_g − 1)"}
pc = mvdist.pcoa(D)
V, ex = pc["vectors"], pc["explained"]
ax1 = V[:, 0] if V.shape[1] else np.zeros(n)
ax2 = V[:, 1] if V.shape[1] > 1 else np.zeros(n)
cs.publish({
    "method": "multivariate.mrpp",
    "methodVersion": "1.0.1",
    "title": "MRPP: multi-response permutation procedure",
    "engine": cs.engine_info("pandas", "numpy", "scipy"),
    "n": n,
    "summary": summary,
    "apa": f"MRPP ({DIST_LABEL[metric]}), δ = {cs.fmt_num(delta)}, A = {a:.3f}, {cs.fmt_p(p)}",
    "statistics": [{"key": "delta", "label": "δ", "value": delta}, {"key": "expected_delta", "label": "E(δ)", "value": res["expected_delta"]},
                   {"key": "a", "label": "A", "value": a}, {"key": "p", "label": "p", "value": p, "format": "p"}],
    "tables": [{"key": "classes", "title": "Mean within-group dissimilarity",
                "columns": [{"key": "group", "label": g, "type": "string"}, {"key": "n", "label": "n", "type": "integer"},
                            {"key": "delta", "label": "δ (mean dissimilarity)", "type": "number"}],
                "rows": [{"group": lv, "n": int(m), "delta": float(cd)} for lv, m, cd in zip(levels, group_n, res["class_delta"])]}],
    "effectSizes": [{"key": "a", "label": "Chance-corrected within-group agreement A", "value": a,
                     "method": "1 − δ / E(δ); 0 = no more alike than chance, 1 = identical within groups"}],
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": [f"{dist_text}; group weights {WEIGHT_TEXT[weighting]}; lower-tail p from {n_perm} label permutations (seed {seed})."
              + (f" Permutations were restricted within {strata_col}." if strata_col else "")],
    "values": values,
    "charts": [cs.chart("ordination", "pcoa-centroids", f"Principal coordinates of the {DIST_LABEL[metric]} dissimilarities by {g}", {
        "x": cs.col(f"PCoA 1 ({100 * ex[0]:.1f}%)" if V.shape[1] else "PCoA 1", ax1),
        "y": cs.col(f"PCoA 2 ({100 * ex[1]:.1f}%)" if V.shape[1] > 1 else "PCoA 2", ax2),
        "group": cs.col(g, df[g].astype(str).to_numpy(), levels=levels)}, controls={"center": "centroid", "spokes": False, "hulls": True})],
})

δ\delta = 0.575 against E(δ)E(\delta) = 0.646 gives AA = 0.11, p = 0.015.

Open Mean within-group dissimilarity. Which management group is the most spread out? Does that fit what ANOSIM's mean ranks show?

06

Do they agree?

Predict

Predict first

ANOSIM gives a sizeable R with p = 0.01. You conclude that the groups' centers differ. A reviewer asks you to check further. What could be driving R?

Different groups' centersUnequal spreadBoth are possible
Reveal

Both are possible. ANOSIM is known to respond strongly to unequal spread as well as to separated centers (Warton, Wright & Wang, 2012). PERMDISP tells you if spread could be involved. On the mite data with strata, ANOSIM gives R = 0.23; MRPP on different groupings gives A = 0.10.

07

Choose ahead of time

Reflect

If you can use only one, PERMANOVA with PERMDISP is the common choice for most group questions, and it handles several factors. Use ANOSIM when only the rank order of the dissimilarities is credible. Use MRPP when you want a within-group homogeneity effect like AA.

Write down which test you'll report before you run them. Running all of them and keeping the best is a forking path.

08

Check your understanding

Checkpoint

Check yourself

With 20 plots there are M=190M = 190 pairs. If rˉB\bar r_B = 101.04 and rˉW\bar r_W = 76.55, what is ANOSIM's R? Give two decimals.

Show the answer

Answer: 0.257870590096504

(101.04−76.55)/(190/2)≈0.26(101.04 - 76.55) / (190 / 2) \approx 0.26.

Check yourself

MRPP gives δ\delta = 0.5746 and E(δ)E(\delta) = 0.6457. What is AA? Give two decimals.

Show the answer

Answer: 0.10998419715343

1−0.5746/0.6457≈0.111 - 0.5746 / 0.6457 \approx 0.11. Rows are about 11% closer within groups than chance would give.

Check yourself

ANOSIM gives R close to 0. What does that mean?

Show the answer

Answer: b

R compares mean ranks. Near 1, the closest pairs all lie within groups; near 0, group membership tells you little about closeness.

Check yourself

ANOSIM gives R = 0.40 and p = 0.002, and PERMDISP gives p = 0.003. What should you report?

Show the answer

Answer: b

ANOSIM responds to spread as well as to separation. Give both results and show the ordination.

Check yourself

What does A=0A = 0 mean in MRPP?

Show the answer

Answer: b

A=1A = 1 would mean identical rows within each group. A=0A = 0 is the chance level, and AA can even fall below 0.

Check yourself

MRPP gives AA = 0.03 and a p-value at the permutation floor. How do you read this?

Show the answer

Answer: b

With enough rows, a small effect can still be hard to reconcile with random labels. AA tells you the size, and p doesn't.

Check yourself

What does a small PERMDISP p-value mean?

Show the answer

Answer: b

PERMDISP speaks about spread alone. That can be a finding in its own right: treatment may make plots more variable.

09

Do it in CodeSplash

In the app

Each is its own method with the same Dissimilarity and Transform first options. Note how the ANOSIM guide data give R = 0.12 and MRPP gives A = 0.037: small, even though p sits at the floor.

Python
import pandas as pd
from scipy.spatial.distance import pdist, squareform
from skbio.stats.distance import DistanceMatrix, anosim, permdisp

df = pd.read_csv("dune.csv")
g = df["Management"].to_numpy()
D = DistanceMatrix(squareform(pdist(df.drop(columns="Management").to_numpy(), "braycurtis")))
print(permdisp(D, g, permutations=999))
print(anosim(D, g, permutations=999))
R
# install.packages("vegan")
library(vegan)
data(dune); data(dune.env)
d <- vegdist(dune, "bray")
permutest(betadisper(d, dune.env$Management), permutations = 999)
anosim(d, dune.env$Management, permutations = 999)
mrpp(dune, dune.env$Management, distance = "bray", weight.type = 3, permutations = 999)
10

Recap

Recap
  • PERMDISP tests spread, not centers, with a bias adjustment for small groups.
  • ANOSIM compares ranks. It's simple, but also sensitive to spread.
  • MRPP gives a chance-corrected within-group effect, AA.
  • A small effect can still reach the p-value floor, so report RR or AA with p.

Concepts in this lesson