Learn R Programming

mclust (version 3.4.7)

plot.mclustDA: Plotting method for MclustDA discriminant analysis.

Description

Plots training and test data, known training data classification, mclustDA test data classification, and/or training errors.

Usage

## S3 method for class 'mclustDA':
plot(x, trainData, testData, \dots)

Arguments

x
The object produced by applying mclustDA with trainingData and classification labels to testData.
trainData
The numeric vector, matrix, or data frame of training observations used to obtain x.
testData
A numeric vector, matrix, or data frame of training observations. Categorical variables are not allowed. If a matrix or data frame, rows correspond to observations and columns correspond to variables.
...
Further arguments to the lower level plotting functions.

Value

  • Plots of the following: training and test data, known training data classification, mclustDA test data classification, and (if test labels were supplied to mclustDA when x was created) test errors.

References

C. Fraley and A. E. Raftery (2002). Model-based clustering, discriminant analysis, and density estimation. Journal of the American Statistical Association 97:611-631. C. Fraley and A. E. Raftery (2006). MCLUST Version 3 for R: Normal Mixture Modeling and Model-Based Clustering, Technical Report no. 504, Department of Statistics, University of Washington.

See Also

mclustDA

Examples

Run this code
n <- 250 ## create artificial data
set.seed(1)
triModal <- c(rnorm(n,-5), rnorm(n,0), rnorm(n,5))
triClass <- c(rep(1,n), rep(2,n), rep(3,n))

odd <- seq(from = 1, to = length(triModal), by = 2)
even <- odd + 1
triMclustDA <- mclustDA(train=list(data=triModal[odd],labels=triClass[odd]),
                   test= list(data=triModal[even],labels=triClass[even]),
                       verbose = TRUE)

names(triMclustDA)
plot(triMclustDA, trainData = triModal[odd], testData = triModal[even])

odd <- seq(from = 1, to = nrow(cross), by = 2)
even <- odd + 1
crossMclustDA <- mclustDA( train=list(data=cross[odd,-1],
                                      labels=cross[odd,1]),
                       test= list(data=cross[even,-1],labels=cross[even,1]),
                       verbose = TRUE)

plot(crossMclustDA, trainData = cross[odd,-1], testData = cross[even,-1])

odd <- seq(from = 1, to = nrow(iris), by = 2)
even <- odd + 1
irisMclustDA <- mclustDA(train=list(data=iris[odd,-5],labels=iris[odd,5]),
                       test= list(data=iris[even,-5],labels=iris[even,5]),
                       verbose = TRUE)

plot(irisMclustDA, trainData = iris[odd,-5], testData = iris[even,-5])

Run the code above in your browser using DataLab