Learn R Programming

biotools (version 2.0)

predict.D2.disc: Classify Multivariate Observations by Mahalanobis Distance

Description

Classify multivariate observations according to D2.disc discriminant analysis.

Usage

## S3 method for class 'D2.disc':
predict(object, newdata, \dots)

Arguments

object
an object of class "D2.disc".
newdata
data.frame or matrix of observations to be classified.
...
arguments based from or to other methods.

Value

  • A list of
  • classa factor containing the classification of each row in newdata.
  • D2a matrix (n x k) containing Mahalanobis distances between each row in newdata and the center of each class.

Details

This function is a method for the generic function predict() for class "D2.disc". It can be invoked by calling predict(x) for an object x of the appropriate class, or directly by calling predict.D2.disc(x) regardless of the class of the object.

See Also

D2.disc

Examples

Run this code
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