pvaluescmaha: Calculate p_values matrix for each species, using Mahalanobis...

View source: R/cmahalanobis.R

pvaluescmahaR Documentation

Calculate p_values matrix for each species, using Mahalanobis distance as a base.

Description

This function takes a dataset, a factor, a p_value method, number of bootstraps and permutation when necessary, and returns a p_values matrix between each pair of the species and a plot if the user select TRUE using Mahalanobis distance for distances calculation.

Usage

pvaluescmaha(
  dataset,
  formula,
  pvalue.method = "chisq",
  num.permutations = 100,
  num.bootstraps = 10,
  plot = TRUE
)

Arguments

dataset

A dataframe.

formula

A factor which you want to calculate the Mahalanobis distances matrix.

pvalue.method

A p_value method used to calculate the matrix, the default value is "chisq".Other methods are "permutation" and "bootstrap".

num.permutations

Number of permutation to specify if you select "permutation" in "pvalue.method". The default value is 100.

num.bootstraps

Number of bootstrap to specify if you select "bootstrap" in "p_value method". The default value is 10.

plot

if TRUE, plot a p_values heatmap. The default value is TRUE.

Value

A list containing the p-values matrix and, optionally, the plot.

Examples

# Calculate p_values of "Species" variable in iris dataset
pvaluescmaha(iris,~Species, pvalue.method = "chisq", num.permutations = 100, num.bootstraps = 10)
# Calculate p_values of "am" variable in mtcars dataset
pvaluescmaha(mtcars,~am, pvalue.method = "chisq", num.permutations = 100, num.bootstraps = 10)

cmahalanobis documentation built on April 3, 2025, 8:51 p.m.