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 <andrewjmarx at gmail.com>
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