mantel_test: Mantel test

View source: R/mantel-test.R

mantel_testR Documentation

Mantel test

Description

Mantel and partial mantel test for dissimilarity matrices

Usage

mantel_test(
  spec,
  env,
  group = NULL,
  env_ctrl = NULL,
  mantel_fun = "mantel",
  spec_select = NULL,
  env_select = NULL,
  na_omit = TRUE,
  spec_dist = NULL,
  env_dist = NULL,
  env_ctrl_dist = NULL,
  seed = 123,
  ...
)

Arguments

spec, env

data frame object.

group

vector for grouping the rows.

env_ctrl

NULL (default), TRUE or a data frame.

mantel_fun

string, function of mantel test.

  • "mantel" will use vegan::mantel() (default).

  • "mantel.randtest" will use ade4::mantel.randtest().

  • "mantel.rtest" will use ade4::mantel.rtest().

  • "mantel.partial" will use vegan::mantel.partial().

spec_select, env_select

NULL (default), numeric or character vector index of columns.

na_omit

if TRUE (default), the incomplete cases will be removed.

spec_dist

NULL (default) or dist_func().

env_dist

NULL (default) or dist_func().

env_ctrl_dist

NULL (default) or dist_func().

seed

a integer value.

...

extra params passing to mantel_fun.

Value

a data.frame.

Author(s)

Hou Yun

Examples

## Not run: 
library(vegan)
data("varespec")
data("varechem")

## set group id of `spec` on columns by `spec_select`
mantel_test(varespec, varechem,
  spec_select = list(spec01 = 1:5, spec02 = 6:12))

## set group id of `spec` on columns by `spec_select`
## set group id of `env` on columns by `env_select`
mantel_test(varespec, varechem,
  spec_select = list(spec01 = 1:5, spec02 = 6:12),
  env_select = list(env01 = 1:5, env02 = 6:10, env03 = 11:14))

## set group id of all data on rows by `group`
set.seed(20211123)
sam_grp <- sample(paste0("sample", 1:3), 24, replace = TRUE)
mantel_test(varespec, varechem, group = sam_grp)

## partial mantel test
m <- matrix(rnorm(24*5), nrow = 24)
mantel_test(varespec, varechem, env_ctrl = m,
mantel_fun = "mantel.partial")

## End(Not run)

Hy4m/linkET documentation built on June 30, 2023, 7:39 p.m.