Learn R Programming

correlation (version 0.8.0)

distance_mahalanobis: Mahalanobis distance and confidence interval (CI)

Description

The Mahalanobis distance (in squared units) measures the distance in multivariate space taking into account the covariance structure of the data. Because a few extreme outliers can skew the covariance estimate, the bootstrapped version is considered as more robust.

Usage

distance_mahalanobis(data, ci = 0.95, iterations = 1000, robust = TRUE, ...)

Arguments

data

A data frame.

ci

Confidence/Credible Interval level. If "default", then it is set to 0.95 (95% CI).

iterations

The number of draws to simulate/bootstrap (when robust is TRUE).

robust

If TRUE, will run a bootstrapped version of the function with i iterations.

...

Additional arguments (e.g., alternative) to be passed to other methods. See stats::cor.test for further details.

Value

Description of the Mahalanobis distance.

References

  • Schwarzkopf, D. S., De Haas, B., & Rees, G. (2012). Better ways to improve standards in brain-behavior correlation analysis. Frontiers in human neuroscience, 6, 200.

Examples

Run this code
# NOT RUN {
library(correlation)

distance_mahalanobis(iris[, 1:4])
distance_mahalanobis(iris[, 1:4], robust = FALSE)
# }

Run the code above in your browser using DataLab