# How do you correlate two non-square matrices with permutations?

I am having difficulty finding a package or finding code for a permutation test to correlate two non-square matrices. Basically, trying to do a mantel test but for non-square matrices. Any help is greatly appreciated.

Edit for more explanation: These matrices represent distance measures between males and females. One distance matrix is genetic data, the other distance matrix is chemical data. I have 19 females and 41 males (19x41 matrix). I don't want to compare males against each other, and females against each other in this test. So, ultimately, I have two distance matrices that I am trying to get a correlation coefficient and p-value estimated from, for example, 100 000 permutations.

Solved: I deconstructed the matrices using the melt command in the package RESHAPE. Then used perm.cor.test in the package JMUOUTLIER, and chose 10 000 permutations.

• Could you explain more specifically what you mean by "correlate ... non-square matrices"? In the Mantel test, the matrices are square because that's a convenient way to represent all possible distances among a set of objects. But what does the non-squareness mean? What do these matrices represent?
– whuber
Jun 13, 2016 at 19:22