A function to perform discriminant analysis based on the squared generalized Mahalanobis distance (D2) of the observations to the center of the groups.
# S3 method for default
D2.disc(data, grouping, pooled.cov = NULL)
# S3 method for D2.disc
print(x, ...)
# S3 method for D2.disc
predict(object, newdata = NULL, ...)
a numeric data.frame
or matrix
(n x p).
a vector of length n containing the class of each observation (row) in data
.
a grouping
-pooled covariance matrix (p x p). If NULL
(default), D2.disc
will automatically compute a pooled covariance matrix.
an object of class "D2.disc"
.
numeric data.frame
or matrix
of observations to be classified.
If NULL
(default), the input data used as argument in D2.disc
will be used.
further arguments.
A list of
the call which produced the result.
numeric matrix; the input data.
a 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.
a matrix containing the vector of means of each class in grouping
.
the pooled covariance matrix.
an object of class confusionmatrix
.
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.
# NOT RUN {
data(iris)
(disc <- D2.disc(iris[, -5], iris[, 5]))
first10 <- iris[1:10, -5]
predict(disc, first10)
predict(disc, iris[, -5])$class
# End (not run)
# }
Run the code above in your browser using DataLab