Last data update: 2014.03.03

R: Mahalanobis Distance
dmahalR Documentation

Mahalanobis Distance

Description

dmahal computes and returns the Mahalanobis distance matrix between the rows of a data matrix.

Usage

dmahal(datos, S)

Arguments

datos

data matrix.

S

covariance matrix.

Value

A dist object with distance information.

Note

There is a function mahalanobis() in stats package which can perform the Mahalanobis distance. While mahalanobis() calculates the Mahalanobis distance with respect to given a center, function dmahal() is designed to calculate the distance between each pair of units given a data matrix.

Author(s)

Itziar Irigoien itziar.irigoien@ehu.es; Konputazio Zientziak eta Adimen Artifiziala, Euskal Herriko Unibertsitatea (UPV-EHU), Donostia, Spain.

Conchita Arenas carenas@ub.edu; Departament d'Estadistica, Universitat de Barcelona, Barcelona, Spain.

References

Pe~nA D. (2002) Analisis de Datos Multivariantes. Mc Graw Hill.

Everitt B. S. and Dunn G. (2001) Applied Multivariate Data Analysis. 2 edition, Edward Arnold, London.

See Also

dist, dbhatta, dgower, dcor, dproc2

Examples

#Generate 10 objects in dimension 2
mu <- rep(0, 2)
Sigma <- matrix(c(10,3,3,2),2,2)

x <- mvrnorm(n=10, rep(0, 2), Sigma)

d <- dmahal(x, Sigma)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ICGE)
Loading required package: MASS
Loading required package: cluster
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ICGE/dmahal.Rd_%03d_medium.png", width=480, height=480)
> ### Name: dmahal
> ### Title: Mahalanobis Distance
> ### Aliases: dmahal
> ### Keywords: multivariate
> 
> ### ** Examples
> 
> #Generate 10 objects in dimension 2
> mu <- rep(0, 2)
> Sigma <- matrix(c(10,3,3,2),2,2)
> 
> x <- mvrnorm(n=10, rep(0, 2), Sigma)
> 
> d <- dmahal(x, Sigma)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>