Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Mahalanobis

Classical and Robust Mahalanobis Distances


Description

This function is a convenience wrapper to mahalanobis offering also the possibility to calculate robust Mahalanobis squared distances using MCD and MVE estimators of center and covariance (from cov.rob)

Usage

Mahalanobis(x, center, cov, method = c("classical", "mcd", "mve"), nsamp = "best", ...)

Arguments

x

a numeric matrix or data frame with, say, p columns

center

mean vector of the data; if this and cov are both supplied, the function simply calls mahalanobis to calculate the result, ignoring the method argument.

cov

covariance matrix (p x p) of the data

method

estimation method used for center and covariance, one of: "classical" (product-moment), "mcd" (minimum covariance determinant), or "mve" (minimum volume ellipsoid).

nsamp

passed to cov.rob, just to make this argument explicit

...

other arguments passed to cov.rob

Details

Any missing data in a row of x causes NA to be returned for that row.

Value

A numeric vector of squared Mahalanobis distances corresponding to the rows of x.

Author(s)

Michael Friendly

See Also

Examples

summary(Mahalanobis(iris[, 1:4]))
summary(Mahalanobis(iris[, 1:4], method="mve"))
summary(Mahalanobis(iris[, 1:4], method="mcd"))

heplots

Visualizing Hypothesis Tests in Multivariate Linear Models

v1.3-8
GPL (>= 2)
Authors
John Fox [aut], Michael Friendly [aut, cre], Georges Monette [ctb], Phil Chalmers [ctb]
Initial release
2021-01-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.