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 H8
#> 5.007867 1.515868 2.640239 0.733542 43.447199 7.290514 87.750750 55.482671
#> H9 H10 H11 H12 H13 H14 H15 H16
#> 1.540124 9.858429 2.441832 6.315752 5.180475 34.016193 1.854172 24.280570
#> H17 H18 H19 H20 H21 H22 H23 H24
#> 26.654962 1.847951 2.839573 5.322244 4.088381 1.715226 4.433984 3.373827
#> H25
#> 19.346698