Learn R Programming

mclust (version 3.4.7)

mclustDA: MclustDA discriminant analysis.

Description

MclustDA training and testing.

Usage

mclustDA(train, test, pro=NULL, G=NULL, modelNames=NULL, prior=NULL, 
         control=emControl(), initialization=NULL, 
         warn=FALSE, verbose=FALSE, ...)

Arguments

train
A list with two named components: data giving the data and labels giving the class labels for the observations in the data.
test
A list with two named components: data giving the data and labels giving the class labels for the observations in the data. The labels are used only to compute the error rate in the print method and can
pro
Optional prior probabilities for each class in the training data.
G
An integer vector specifying the numbers of mixture components (clusters) for which the BIC is to be calculated. The default is G=1:9.
modelNames
A vector of character strings indicating the models to be fitted in the EM phase of clustering. The help file for mclustModelNames describes the available models. The default is c("E", "V") for univariate data and
prior
The default assumes no prior, but this argument allows specification of a conjugate prior on the means and variances through the function priorControl.
control
A list of control parameters for EM. The defaults are set by the call emControl().
initialization
A list containing zero or more of the following components:
  • hcPairs
{ A matrix of merge pairs for hierarchical clustering such as produced by function hc. The default is to compute a hierarchical clustering tree

Value

  • A list with the following components:
  • testA list with the following components: [object Object],[object Object],[object Object]
  • trainingA list with the following components: [object Object],[object Object],[object Object]
  • summaryA data frame summarizing the mclustDA results including the mixture models and numbers of components for the training classes.

item

  • warn
  • verbose
  • ...

code

do.call

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.

Details

mclustDA combines functions mclustDAtrain and mclustDAtest and their summaries. This is suitable when all test data are available in advance, so that the training model is only used once.

See Also

plot.mclustDA, mclustDAtrain, mclustDAtest, classError

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