pvaluescmink: Calculate the p_values matrix or matrices (two or more) for...

View source: R/cmahalanobis.R

pvaluescminkR Documentation

Calculate the p_values matrix or matrices (two or more) for each factor inside variable or variables (two or more), using Minkowski dissimilarity/distance as a base.

Description

Using the Minkowski dissimilarity/distance for the dissimilarities/distances calculation, this function takes a dataframe, a variable or variables (two or more), a p_value method such as "bootstrap" and "permutation" and returns the p_values matrix or matrices (two or more) between each pair of factors and a plot or plots (two or more) if the user select TRUE or leaves the parameter without argument.

Usage

pvaluescmink(
  dataset,
  formula,
  pvalue.method = "permutation",
  p = 3,
  plot = TRUE,
  seed = NULL,
  min_group_size = 3
)

Arguments

dataset

A dataframe.

formula

A variable or variables (two or more) with factors which you want to calculate the Minkowski dissimilarities/distances matrix or matrices (two or more).

pvalue.method

A p_value method used to calculate the matrix or matrices (two or more), the default value is "permutation". Another method is "bootstrap".

p

Order of the Minkowski dissimilarities/distances. The default value is 3.

plot

if TRUE, plot the p_values heatmap or heatmaps (two or more). The default value is TRUE.

seed

Optionally, set a seed for "bootstrap" and "permutation".

min_group_size

Minimum group size to maintain. The default value is 3, therefore groups, inside variables, with less than 3 observations will be discarded.

Value

A list containing a matrix of p_values and, optionally, the plot.

Note

When p < 1, the Minkowski distance is a "dissimilarity" measure. When p >= 1, the triangle inequality property is satisfied and we say "Minkowski distance".

Examples

# Example with iris dataset

# data(iris)

# Calculate p_values of "Species" variable in iris dataset

pvaluescmink(iris,~Species, p = 3, pvalue.method = "permutation")

# Example with mtcars dataset
data(mtcars)

# Calculate p_values of "am" variable in mtcars dataset

pvaluescmink(mtcars,~am, p = 3, 
pvalue.method = "permutation", seed = 100)


cmahalanobis documentation built on Sept. 14, 2025, 5:09 p.m.