Computes the squared Mahalanobis distance of all rows in x.
Arguments
- x
A
CompositionMatrixor anILRobject.- center
A
numericvector giving the mean vector of the distribution. If missing, will be estimated fromx.- cov
A
numericmatrix giving the covariance of the distribution. If missing, will be estimated fromx.- ...
Extra parameters to be passed to
MASS::cov.rob(). Only used ifrobustisTRUE.- robust
A
logicalscalar: should robust location and scatter estimation be used?- method
A
characterstring specifying the method to be used. It must be one of "mve" (minimum volume ellipsoid) or "mcd" (minimum covariance determinant). Only used ifrobustisTRUE.
Value
A numeric vector.
See also
Other statistics:
aggregate(),
condense(),
covariance(),
dist(),
margin(),
mean(),
pip(),
quantile(),
scale(),
variance(),
variance_total(),
variation()
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.8416641 0.5268597 2.8217025 0.7805709 20.4639923 6.8908961 33.2466487
#> H8 H9 H10 H11 H12 H13 H14
#> 32.3471329 1.7015288 8.5956701 2.0374883 5.8768012 5.7154573 11.3813839
#> H15 H16 H17 H18 H19 H20 H21
#> 1.9683500 8.3199851 15.0207721 1.8352990 2.8291314 4.6339628 1.4407278
#> H22 H23 H24 H25
#> 1.0102074 4.9903095 2.1507501 7.0326380
