Computes the squared Mahalanobis distance of all rows in x
.
Arguments
- x
A
CompositionMatrix
or anILR
object.- center
A
numeric
vector giving the mean vector of the distribution. If missing, will be estimated fromx
.- cov
A
numeric
matrix giving the covariance of the distribution. If missing, will be estimated fromx
.- ...
Extra parameters to be passed to
MASS::cov.rob()
. Only used ifrobust
isTRUE
.- 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 ifrobust
isTRUE
.
Value
A numeric
vector.
See also
Examples
## Data from Aitchison 1986
data("hongite")
## Coerce to compositional data
coda <- as_composition(hongite)
## Mahalanobis distance
mahalanobis(coda)
#>
#> H1 H2 H3 H4 H5 H6 H7
#> 4.6935346 0.4862639 1.8203070 0.9564282 4.6278361 5.6478569 7.0792602
#> H8 H9 H10 H11 H12 H13 H14
#> 8.4724638 1.1452246 22.4936169 1.3734240 5.2150046 5.5223415 7.1744957
#> H15 H16 H17 H18 H19 H20 H21
#> 1.9366162 9.0374393 4.7712623 1.7101898 3.2622612 2.9144878 1.2990165
#> H22 H23 H24 H25
#> 1.6917684 11.1555514 2.9663402 2.0780653