maha: Compute the (squared) Mahalanobis distance between two groups...

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

View source: R/cp00-utility.R

Description

The Mahalanobis distance between two groups of vectors

Usage

1
maha(data, groups, method = "mve")

Arguments

data

A matrix with columns representing features (or variables) and rows representing independent samples

groups

A factor or logical vector with length equal to the number of rows (samples) in the data matrix

method

A character string determining the method that should be used to estimate the covariance matrix. The default value of "mve" uses the cov.mve function from the MASS package. The other valid option is "var", which uses the var function from the standard stats package.

Details

The Mahalanobis distance between two groups of vectors is the distance between their centers, computed in the equivalent of a principal component space that accounts for different variances.

Value

Returns a numeric vector of length 1.

Author(s)

Kevin R. Coombes krc@silicovore.com, P. Roebuck proebuck@mdanderson.org

References

Mardia, K. V. and Kent, J. T. and Bibby, J. M.
Multivariate Analysis.
Academic Press, Reading, MA 1979, pp. 213–254.

See Also

cov.mve, var

Examples

1
2
3
4
5
nFeatures <- 40
nSamples <- 2*10
dataset <- matrix(rnorm(nSamples*nFeatures), ncol=nSamples)
groups <- factor(rep(c("A", "B"), each=10))
maha(dataset, groups)

Example output

        [,1]
[1,] 2.58538

GenAlgo documentation built on Oct. 23, 2020, 7:28 p.m.