Learn R Programming

biotools (version 2.0)

D2.disc: Discriminant Analysis Based on Mahalanobis Distance

Description

A function to perform discriminant analysis based on the squared generalized Mahalanobis distance (D2) of the observations to the center of the groups.

Usage

D2.disc(data, grouping, pooled.cov = NULL)

Arguments

data
a numeric data.frame or matrix (n x p).
grouping
a vector of length n containing the class of each observation (row) in data.
pooled.cov
a grouping-pooled covariance matrix (p x p). If NULL (default), D2.disc will automatically compute a pooled covariance matrix.

Value

  • A list of
  • D2a matrix containing the Mahalanobis distances between each row of data and the center of each class of grouping. In addition, the original and the predicted (lowest distance) class are displayed, as well as a chacater vector indicating where the misclassification has occured.
  • meansa matrix containing the vector of means of each class in grouping.
  • pooledthe pooled covariance matrix.
  • confusion.matrixan object of class confusionmatrix.

References

Manly, B.F.J. (2004) Multivariate statistical methods: a primer. CRC Press. (p. 105-106). Mahalanobis, P.C. (1936) On the generalized distance in statistics. Proceedings of The National Institute of Sciences of India, 12:49-55.

See Also

D2.dist, confusionmatrix, lda

Examples

Run this code
data(iris)
D2.disc(iris[, -5], iris[, 5])

# End (not run)

Run the code above in your browser using DataLab