mahaldis: Mahalanobis Distance

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

mahaldis measures the pairwise Mahalanobis (1936) distances between individual objects.

Usage

1

Arguments

x

matrix containing the variables. NAs are not tolerated.

Details

mahaldis computes the Mahalanobis (1936) distances between individual objects. The Mahalanobis distance takes into account correlations among variables and does not depend on the scales of the variables.

mahaldis builds on the fact that type-II principal component analysis (PCA) preserves the Mahalanobis distance among objects (Legendre and Legendre 2012). Therefore, mahaldis first performs a type-II PCA on standardized variables, and then computes the Euclidean distances among (repositioned) objects whose positions are given in the matrix \mathbfG. This is equivalent to the Mahalanobis distances in the space of the original variables (Legendre and Legendre 2012).

Value

an object of class dist.

Author(s)

Pierre Legendre pierre.legendre@umontreal.ca

http://www.bio.umontreal.ca/legendre/indexEn.html

Ported to FD by Etienne Laliberté.

References

Legendre, P. and L. Legendre (2012) Numerical Ecology. 3nd English edition. Amsterdam: Elsevier.

See Also

mahalanobis computes the Mahalanobis distances between groups of objects, not individual objects.

Examples

1
2
3
4
5
6
7
8
9
mat <- matrix(rnorm(100), 50, 20)

ex1 <- mahaldis(mat)

ex1 <- gowdis(dummy$trait)
ex1

# check attributes
attributes(ex1)

Example output

Loading required package: ade4
Loading required package: ape
Loading required package: geometry
Loading required package: vegan
Loading required package: permute
Loading required package: lattice
This is vegan 2.5-7
          sp1       sp2       sp3       sp4       sp5       sp6       sp7
sp2 0.2181884                                                            
sp3 0.5240052 0.6678082                                                  
sp4 0.6737443 0.5610028 0.8225701                                        
sp5 0.5291113 0.8145699 0.4862253 0.4843264                              
sp6 0.6100161 0.5932587 0.2784736 0.7073925 0.6067323                    
sp7 0.4484235 0.6863374 0.4848663 0.5575126 0.3023416 0.6187844          
sp8 0.4072834 0.2039443 0.5958904 0.2390962 0.5585525 0.4470207 0.7030186
$Labels
[1] "sp1" "sp2" "sp3" "sp4" "sp5" "sp6" "sp7" "sp8"

$Size
[1] 8

$Metric
[1] "Gower"

$Types
[1] "C" "C" "N" "N" "O" "O" "B" "B"

$class
[1] "dist"

FD documentation built on May 2, 2019, 6:08 p.m.