mantel.test: Mantel Test

View source: R/mantel-test.R

mantel.testR Documentation

Mantel Test

Description

A simple function to do a permutation-based Mantel test. The data can either be two distance/similarity matrices or (x, y, z) data.

Usage

mantel.test(
  M1 = NULL,
  M2 = NULL,
  x = NULL,
  y = NULL,
  z = NULL,
  resamp = 999,
  latlon = FALSE,
  quiet = FALSE
)

Arguments

M1

similarity/distance matrix 1

M2

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 suppressed during execution.

Details

Typical usages are

mantel.test(M1, M2, x = NULL, y = NULL, z = NULL, resamp = 999, 
            latlon = FALSE, quiet = FALSE)

mantel.test(x, y, z, M1 = NULL, M2 = NULL, resamp = 999, latlon = FALSE, 
            quiet = FALSE)

Missing values are treated through pairwise deletion.

Value

An object of class "Mantel" is returned, consisting of a list with two components:

correlation

the value for the Mantel correlation.

p

the randomization-based two-sided p-value.

Author(s)

Ottar N. Bjornstad onb1@psu.edu

Examples

# 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 = 999)

ncf documentation built on May 7, 2022, 5:05 p.m.