Learn R Programming

compositions (version 1.01-1)

MahalanobisDist: Compute Mahalanobis distances based von robust Estimations

Description

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

Usage

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
giveGeometry
If true an atrributes "center" and "cov" given the center and the idt-variance used for the calculations.

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.

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.

See Also

dist, OutlierClassifier1

Examples

Run this code
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)))

Run the code above in your browser using DataLab