Learn R Programming

nexus (version 0.3.0)

mahalanobis: Mahalanobis Distance

Description

Computes the squared Mahalanobis distance of all rows in x.

Usage

# S4 method for CompositionMatrix
mahalanobis(x, center, cov, ..., robust = TRUE, method = c("mve", "mcd"))

# S4 method for ILR mahalanobis(x, center, cov, ..., robust = TRUE, method = c("mve", "mcd"))

Value

A numeric vector.

Arguments

x

A CompositionMatrix or an ILR object.

center

A numeric vector giving the mean vector of the distribution. If missing, will be estimated from x.

cov

A numeric matrix giving the covariance of the distribution. If missing, will be estimated from x.

...

Extra parameters to be passed to MASS::cov.rob(). Only used if robust is TRUE.

robust

A logical scalar: should robust location and scatter estimation be used?

method

A character string specifying the method to be used. It must be one of "mve" (minimum volume ellipsoid) or "mcd" (minimum covariance determinant). Only used if robust is TRUE.

Author

N. Frerebeau

See Also

stats::mahalanobis()

Other statistics: aggregate(), condense(), covariance(), dist, margin(), mean(), pip(), quantile(), scale(), variance(), variance_total(), variation()

Examples

Run this code
## Data from Aitchison 1986
data("hongite")

## Coerce to compositional data
coda <- as_composition(hongite)

## Mahalanobis distance
mahalanobis(coda)

Run the code above in your browser using DataLab