# Can the Mantel test be extended to asymmetric matrices?

The Mantel test is usually applied to symmetric distance/difference matrices. As far as I understand, an assumption of the test is that the measure used to define differences must be at least a semi-metric (meet the standard requirements of a metric but not the triangle inequality).

Can the assumption of symmetry be relaxed (giving a pre-metric)? Is it possible to apply the permutation test in this case, using the full matrix?

It doesn't need to be extended. The original Mantel test, as presented in Mantel's 1967 paper, allows for asymmetric matrices. Recall that this test compares two $n\times n$ distance matrices $X$ and $Y$.

We may at this point anticipate a modification of our statistic which will simplify the statistical procedures to be developed below. The modification is to remove the restriction $i\lt j$, and to replace it only by the restriction $i\ne j$. Where $X_{ij} = X_{ji}$ and $Y_{ij} = Y_{ji}$, the effect of the modification is simply to double exactly the value of the summation. However, the procedures then developed are appropriate even when the distance relationships are not symmetric, that is, when it is possible that $X_{ij} \ne X_{ji}$ and the $Y_{ij} \ne Y_{ji}$; a particular case then covered is where $X_{ij} = -X_{ji}, Y_{ij} = -Y_{ji}$ ...

Symmetry appears to be an artificial condition in much software, such as the ade4 package for R, which uses objects of a "dist" class to store and manipulate distance matrices. The manipulation functions assume the distances are symmetric. For this reason you cannot apply its mantel.rtest procedure to asymmetric matrices--but that is purely a software limitation, not a property of the test itself.

The test itself does not appear to require any properties of the matrices. Obviously (by virtue of the explicit reference to antisymmetric references at the end of the preceding passage) it doesn't even need that the entries in $X$ or $Y$ are positive. It merely is a permutation test that uses some measure of correlation of the two matrices (considered as vectors with $n^2$ elements) as a test statistic.

In principle we can list the $n!$ possible permutations of our data, compute $Z$ [the test statistic] for each permutation, and obtain the null distribution of $Z$ against which the observed value of $Z$ can be judged.

[ibid.]

In fact, Mantel explicitly pointed out that the matrices do not have to be distance matrices and he emphasized the importance of this possibility:

The general case formulas will be appropriate also for cases where the $X_{ij}$'s and $Y_{ij}$'s do not follow the arithmetic and geometric regularities imposed in the clustering problem; e.g., $X_{ik} \le X_{ij} + X_{jk}$. It is the applicability of the general procedure to arbitrary $X_{ij}$'s and $Y_{ij}$'s which underlies its extension to a wider variety of problems ...

(The example states the triangle inequality.)

As an example, he offered "the study of interpersonal relationships" in which "we have $n$ individuals and 2 different measures, symmetric or asymmetric, relating each individual to the remaining $n-1$" (emphasis added).

In an appendix, Mantel derived the "permutational variance of $Z=\sum\sum X_{ij}Y_{ij}$, making no stronger assumption than that the diagonal elements of the matrices are constants, potentially nonzero.

In conclusion, from the very beginning every one of the metric axioms has been explicitly considered and rejected as being inessential to the test:

1. "Distances" may be negative.

2. "Distances" between an object and itself may be nonzero.

3. The triangle inequality need not hold.

4. "Distances" need not be symmetric.

I will end by remarking that Mantel's proposed statistic, $Z=\sum_{i,j} X_{ij}Y_{ij}$, may work poorly for non-symmetric distances. The challenge is to find a test statistic that effectively distinguishes two such matrices: use that in the permutation test instead of the sum of products.

This is an example of the test in R. Given two distance matrices x and y, it returns a sample of the permutation distribution (as a vector of values of the test statistic). It does not require that x or y have any particular properties at all. They only need to be the same size of square matrix.

mantel <- function(x, y, n.iter=999, stat=function(a,b) sum(a*b)) {
permute <- function(z) {
i <- sample.int(nrow(z), nrow(z))
return (z[i, i])
}
sapply(1:n.iter, function(i) stat(x, permute(y)))
}

• What do you mean by "that"? Have you ever seen research validating the ability of the Mantel test to relate two asymmetric matrices? Do you know of any alternative way to relate asymmetric matrices? Commented Apr 27, 2017 at 3:32
• Related question Commented Apr 27, 2017 at 3:36