Learn R Programming

mclust (version 4.1)

predict.Mclust: Cluster multivariate observations by Gaussian finite mixture modeling

Description

Cluster prediction for multivariate observations based on Gaussian finite mixture models estimated by Mclust.

Usage

## S3 method for class 'Mclust':
predict(object, newdata, \dots)

Arguments

object
an object of class "Mclust" resulting from a call to Mclust.
newdata
a data frame or matrix giving the data. If missing the clustering data obtained from the call to Mclust are classified.
...
further arguments passed to or from other methods.

Value

  • Returns a list of with the following components:
  • classificationa factor of predicted cluster labels for newdata.
  • za matrix whose [i,k]th entry is the probability that observation i in newdata belongs to the kth cluster.

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, A. E. Raftery, T. B. Murphy and L. Scrucca (2012). mclust Version 4 for R: Normal Mixture Modeling for Model-Based Clustering, Classification, and Density Estimation. Technical Report No. 597, Department of Statistics, University of Washington.

See Also

Mclust.

Examples

Run this code
model <- Mclust(faithful)

# predict cluster for the observed data
pred <- predict(model) 
str(pred)
pred$z              # equal to model$z
pred$classification # equal to 
plot(faithful, col = pred$classification, pch = pred$classification)

# predict cluster over a grid
grid <- apply(faithful, 2, function(x) seq(min(x), max(x), length = 50))
grid <- expand.grid(eruptions = grid[,1], waiting = grid[,2])
pred <- predict(model, grid)
plot(grid, col = mclust.options()$classPlotColors[pred$classification], pch = 15, cex = 0.5)
points(faithful, pch = model$classification)

Run the code above in your browser using DataLab