Perform mantel test on subset of distance matrix

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Perform mantel test on subset of distance matrix

anjama
I'm trying to perform a mantel test that ignores specific pairs in my
distance matrices. The reasoning is that some geographic distances
below a certain threshold suffer from spatial autocorrelation, or
perhaps ecological relationships become less relevant that stochastic
processes above a certain threshold.

The problem is that I can't find a way to do it. If I replace values
in either or both of the distance matrices with NA, mantel.rtest (ade4
package) gives the following error: Error in if (any(distmat < tol))
warning("Zero distance(s)") : missing value where TRUE/FALSE needed

Here's a trivial example that tries to exclude elements of the first
matrix that equal 11:

library(ade4)
a <- matrix(data = 1:36, nrow = 6)
b <- matrix(data = 1:36, nrow = 6)
a[a==11] <- NA
mantel.rtest(as.dist(a), as.dist(b))

Is there a way to do this, either with this package or another?

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Perform mantel test on subset of distance matrix

Sarah Goslee
Hi Andrew,

Yes, you cannot have NA values in your matrices.
Instead, you could incorporate a model matrix.

See Legendre, P. & Fortin, M.J. Vegetatio (1989) 80: 107.
https://doi.org/10.1007/BF00048036
for ideas.

Sarah

On Sun, Dec 31, 2017 at 12:55 PM, Andrew Marx <[hidden email]> wrote:

> I'm trying to perform a mantel test that ignores specific pairs in my
> distance matrices. The reasoning is that some geographic distances
> below a certain threshold suffer from spatial autocorrelation, or
> perhaps ecological relationships become less relevant that stochastic
> processes above a certain threshold.
>
> The problem is that I can't find a way to do it. If I replace values
> in either or both of the distance matrices with NA, mantel.rtest (ade4
> package) gives the following error: Error in if (any(distmat < tol))
> warning("Zero distance(s)") : missing value where TRUE/FALSE needed
>
> Here's a trivial example that tries to exclude elements of the first
> matrix that equal 11:
>
> library(ade4)
> a <- matrix(data = 1:36, nrow = 6)
> b <- matrix(data = 1:36, nrow = 6)
> a[a==11] <- NA
> mantel.rtest(as.dist(a), as.dist(b))
>
> Is there a way to do this, either with this package or another?
>


--
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.