How this calculation works
Supply two complete distance or dissimilarity matrices with matching row and column order. If the first matrix lists sites A through E, the second must refer to those same sites in that sequence. A matching dimension alone is insufficient. Distances can represent different units because the correlation standardizes their scale, but their substantive meaning still needs documentation.
r=cor(vecLower(D1),vecLower(D2)); Spearman uses average ranks. Permute D1 jointly by rows and columns; p=(1+#{r_perm≥r})/(B+1).A worked example
Distances from positions (0,1,3,6,10) and (0,2,3,7,9) give Pearson Mantel r≈0.919975090.
Good to know
5–80 matched objects, complete symmetric nonnegative matrices with zero diagonal and varying off-diagonal entries; Pearson or Spearman Mantel on same page, prespecified positive-association test; 999–9999 seeded unrestricted permutations with 20 million pair-evaluation cap. No partial Mantel, restricted spatial null or causal conclusion.
Reference: vegan — mantel (opens in a new tab) ↗
Two matrices must describe the same objects
Supply two complete distance or dissimilarity matrices with matching row and column order. If the first matrix lists sites A through E, the second must refer to those same sites in that sequence. A matching dimension alone is insufficient. Distances can represent different units because the correlation standardizes their scale, but their substantive meaning still needs documentation.
Both matrices must be symmetric, nonnegative, and zero on the diagonal. The calculator extracts one triangle and excludes self-distances, so a five-object example has ten distinct pairs. Those ten pairs are not ten independent observations: each object participates in several pairs. This dependence is the reason the test permutes object labels instead of applying an ordinary correlation significance formula.
Compare this with the Distance correlation independence test calculator for paired vectors. Correlates two supplied relational distance matrices and permutes object labels jointly by rows and columns. Existing distance correlation consumes paired feature vectors and double-centers their Euclidean distances; it does not compute the Mantel lower-triangle statistic.
The Mantel statistic is a pairwise correlation
Pearson Mantel correlation is the ordinary correlation between corresponding lower-triangle entries. It describes whether pairs far apart in one representation also tend to be far apart in the other. Spearman mode first replaces each triangle's entries by average ranks for ties, then correlates the ranks. The two modes answer linear-distance and monotone-distance questions respectively.
A high statistic supports descriptive alignment of the two relational structures. It does not show that one distance causes the other, establish agreement in their physical units, or guarantee that either matrix embeds in Euclidean space. Different matrices can share a strong rank relationship while having very different ratios of near to far separation. Inspect the underlying distances as well as r.
Relabel whole objects in the permutation test
A valid unrestricted permutation applies the same index permutation to both rows and columns of one matrix. The other matrix stays fixed. This preserves all within-matrix distances while breaking the identity correspondence between objects. Permuting rows alone generally destroys symmetry and represents neither a relabeling of objects nor the intended Mantel null distribution.
This page tests positive association, counting randomized correlations at least as large as the observed one and using a plus-one Monte Carlo p. The null assumes exchangeable object labels. Spatial or temporal structure may require restricted permutations that this calculator does not offer. A generic shuffle cannot automatically accommodate blocks, related individuals, matched sampling strata, or repeated measurements.
Work through the five-object default
The first default matrix contains absolute separations among positions 0, 1, 3, 6, and 10. The second uses positions 0, 2, 3, 7, and 9. These are synthetic measurements of the same five objects. Distances are constructed before entering the page; the calculator receives the full matrices and does not infer coordinates from their labels.
Pearson correlation of the ten corresponding distances is approximately 0.91997509. Independent enumeration of all 120 object permutations gives an upper-tail probability of 1 divided by 120, or 0.00833333. Seeded sampling with replacement can produce a different Monte Carlo result. Treat the exhaustive calculation as a small-example check, while retaining the reported simulation settings for the browser calculation.
Read heatmaps together with the pair scatter
The paired heatmaps use one shared object order, making corresponding matrix cells directly comparable. Their diagonals are self-distances and should remain zero. The triangular scatter assigns one point to each unordered pair, with its first and second dissimilarity on the two axes. A rising cloud explains positive correlation without incorrectly treating a heatmap pixel as an independent sample.
A label-permutation illustration should move an object's row and column together. It does not shuffle individual distances freely. Tied entries appear at repeated coordinates or ranks and can reduce the number of distinct randomized statistics. An apparently clean line in this small display is a worked example of alignment, not a guarantee that a larger real dataset follows a single linear relation.
Know where the question becomes unsupported
At least five and at most eighty matched objects are accepted, with varying off-diagonal entries on both sides. A constant triangle has zero correlation denominator and cannot yield a defined Mantel statistic. Missing dissimilarities are rejected rather than silently deleting selected pairs; selective pair deletion can alter the relationship and the exchangeability structure in ways a complete-matrix test does not describe.
The simulation count ranges from 999 through 9,999, subject to a twenty-million pair-evaluation cap. The calculator provides neither partial Mantel adjustment nor a spatially restricted null. In particular, conditioning on a third distance matrix is not a routine substitute for modeling confounding. Plan a design-specific analysis when similarities are strongly constrained by geography or a sampling hierarchy.
Choose relational comparison rather than vector dependence
The nearby distance-correlation calculator starts from paired feature vectors and double-centers distances to measure a broader dependence target. This Mantel page starts from two user-supplied relational matrices and correlates their triangle entries. Supplying matrices of genetic, ecological, or transportation dissimilarities is a materially different input and hypothesis, even when both tools use a permutation strategy.
Save the identity order, distance definitions, Pearson or Spearman choice, observed correlation, simulation count, seed, and p with your analysis. A weak result may reflect low power in a small number of objects or a relationship unlike the chosen correlation. A strong result remains descriptive evidence about corresponding separations under the stated null; it is not proof of a causal or mechanistic connection.
A few questions, answered
May the two matrices use different units?
Yes. Correlation standardizes scale, but the objects and ordering must match and the dissimilarities must answer a meaningful relational question.
Why permute rows and columns together?
Both indices identify objects. Joint permutation preserves each matrix as the same relational structure with relabeled objects.
Are the n(n-1)/2 distances independent observations?
No. Pairs share objects; the permutation reference addresses label exchangeability rather than treating pair entries as IID samples.
Can this control for a third distance matrix?
No. Partial Mantel and restricted permutations are outside this calculator.