vegandevs / vegan

R package for community ecologists: popular ordination methods, ecological null models & diversity analysis
https://vegandevs.github.io/vegan/
GNU General Public License v2.0
451 stars 98 forks source link

p-value for negative correlations in Mantel #410

Open YiJessePi opened 3 years ago

YiJessePi commented 3 years ago

Hello, I'm using mantel to correlate two different distance matrices. From time to time I'm getting a negative (and not negligible) correlation. In this cases the p-value is close to 1 since most of the permutations have higher r value (even if negative) than the tested r. I suspect that for negative r values the p-value should be calculated differently (one option is by the absolute value of r for both test and permutations; or for negative just by counting how many times r is smaller than permutations). BTW, if you have any sense on how to interpret negative mantel values I would be very grateful!

jarioksa commented 3 years ago

Mantel test is one-sided: negative values are worse than zero and get higher P-values, preferably above P=0.5 or close to 1.

It has been suggested often that there should be a two-sided test, but I have no intention to implement one. That would also indicate that the P-values for the positive relation should be doubled, that is, if you had P=0.04, it should be made to P=0.08 if you think that negative values should be treated symmetrically.

The reason why I haven't implemented two-sided tests is that I really do not have an idea how to interpret negative Mantel values. These would indicate that, say, in spatial context, points far away from each other are more similar than neighbouring points. That could be possible in a patchy or mosaic-like systems, but to analyse that kind of cases you should use something else than Mantel tests.

jarioksa commented 3 years ago

Although I won't implement two-sided Mantel test, you can perform it in vegan: mantel has permustats method that extracts permutation results, and permustats has summary method where you can select the test direction. If m is your Mantel test result, then

summary(permustats(m), alternative="two.sided")

will give you P-values from a two-sided test. You can also specifically select one-sided test for negative values (alternative = "less"), but if you first look at the test result and then select a test type to give you the lower P-value, you are committing an unforgivable sin.

YiJessePi commented 3 years ago

Hi, Thanks for your reply. Correct me if I'm wrong- since mantel is permutation based test, it could work for negative correlations pretty easily just by calculating the p-value relative to the absolute r value of the correlation relative to absolute r of permutations. Negative correlation is not easy to interpret, but I'm actually interested in the explained variance, which I don't want to miss only because the one-sided test. I totally agree regarding the unforgivable sin, its a bad practice and should not be done.

jarioksa commented 3 years ago

Using absolute values is regarded as OK as long as the permutation values have a symmetric distribution. The permustats function also has densityplot that can help in inspecting this. Personally, I do think that using absolute values is a bit weird: you take positive values as a support of negative values. Sounds ultra-frequentist. The summary.permustats does not take this approach, mainly because of its dependence on symmetric permutation distribution. Think about it: you have r=–0.3, and low P-value in two-sided tests means that r is either higher than zero or lower than zero.