mantel.test {ncf} | R Documentation |
A simple function to do a permutation-based Mantel test. The data can either be two distance/similarity matrices or (x, y, z) data.
mantel.test(M1 = NULL, M2 = NULL, x = NULL, y = NULL, z = NULL, resamp = 1000, latlon = FALSE, quiet = FALSE)
M1, M2 |
similarity/distance matrix 1, and similarity/distance matrix 2 |
x |
vector of length n representing the x coordinates (or longitude; see latlon). |
y |
vector of length n representing the y coordinates (or latitude). |
z |
matrix of dimension n x p representing p observation at each location. |
resamp |
the number of resamples for the null distribution. |
latlon |
if TRUE, coordinates are latitude and longitude. |
quiet |
if TRUE the counter is supressed during execution. |
Typical usages are
mantel.test(M1, M2, x = NULL, y = NULL, z = NULL, resamp = 1000, latlon = FALSE, quiet = FALSE) mantel.test(x, y, z, M1=NULL, M2=NULL, resamp = 1000, latlon = FALSE, quiet = FALSE)
Missing values are are treated through pairwise deletion.
An object of class "Mantel" is returned, consisting of a list with two components:
correlation |
is the value for the Mantel correlation. |
p |
the randomization-based two-sided p-value. |
Ottar N. Bjornstad onb1@psu.edu
#first generate some sample data x <- expand.grid(1:20, 1:5)[,1] y <- expand.grid(1:20, 1:5)[,2] #z data from an exponential random field z <- cbind( rmvn.spa(x=x, y=y, p=2, method="exp"), rmvn.spa(x=x, y=y, p=2, method="exp") ) #the Mantel test mantel.test(x=x, y=y, z=z[,1], resamp=10)