# mahalanobisdist: Compute Mahalanobis distances based von robust Estimations

### Description

MahalanobisDist computes the Mahalanobis distances to the center or to other observations.

### Usage

 ```1 2 3 4 5 6 7 8 9``` ```MahalanobisDist(x,center=NULL,cov=NULL,inverted=FALSE,...) ## S3 method for class 'rmult' MahalanobisDist(x,center=NULL,cov=NULL,inverted=FALSE,..., goodOnly=NULL,pairwise=FALSE,pow=1, robust=FALSE,giveGeometry=FALSE) ## S3 method for class 'acomp' MahalanobisDist(x,center=NULL,cov=NULL,inverted=FALSE,..., goodOnly=NULL, pairwise=FALSE,pow=1,robust=FALSE,giveGeometry=FALSE) ```

### Arguments

 `x` the dataset `robust` logical or a robust method description (see `robustnessInCompositions`) specifiying how the center and covariance matrix are estimated,if not given. `...` Further arguments to `solve`. `center` An estimated for the center (mean) of the dataset. If center is NULL it will be estimated based using the given robust option. `cov` An estimated for the spread (covariance matrix) of the dataset. If cov is NULL it will be estimated based using the given robust option. `inverted` TRUE if the inverse of the covariance matrix is given. `goodOnly` An vector of indices to the columns of x that should be used for estimation of center and spread. `pairwise` If FALSE the distances to the center are returned as a vector. If TRUE the distances between the cases are returned as a distance matrix. `pow` The power of the Mahalanobis distance to be used. 1 correponds to the square root of the squared distance in transformed space, like it is defined in most books. The choice 2 corresponds to what is implemented in many software package including the `mahalanobis` function in R. `giveGeometry` If true an atrributes `"center"` and `"cov"` given the center and the idt-variance used for the calculations.

### Details

The Mahalanobis distance is the distance in a linearly transformed space, where the linear transformation is selected in such a way,that the variance is the unit matrix. Thus the distances are given in multiples of standard deviation.

### Value

Either a vector of Mahalanobis distances to the center, or a distance matrix (like from `dist`) giving the pairwise Mahalanobis distances of the data.

### Note

Unlike the `mahalanobis` function this function does not be default compute the square of the mahalanobis distance. The pow option is provided if the square is needed.
The package robustbase is required for using the robust estimations.

### Author(s)

K.Gerald v.d. Boogaart http://www.stat.boogaart.de

`dist`, `OutlierClassifier1`

### Examples

 ```1 2 3 4 5 6 7``` ```data(SimulatedAmounts) data5 <- acomp(sa.outliers5) cl <- ClusterFinder1(data5,sigma=0.4,radius=1) plot(data5,col=as.numeric(cl\$types),pch=as.numeric(cl\$types)) legend(1,1,legend=levels(cl\$types),xjust=1,col=1:length(levels(cl\$types)), pch=1:length(levels(cl\$types))) ```

Search within the compositions package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.