Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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, ...)

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:

classification

a factor of predicted cluster labels for newdata.

z

a matrix whose [i,k]th entry is the probability that observation i in newdata belongs to the kth cluster.

Author(s)

Luca Scrucca

See Also

Examples

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)

mclust

Gaussian Mixture Modelling for Model-Based Clustering, Classification, and Density Estimation

v5.4.10
GPL (>= 2)
Authors
Chris Fraley [aut], Adrian E. Raftery [aut] (<https://orcid.org/0000-0002-6589-301X>), Luca Scrucca [aut, cre] (<https://orcid.org/0000-0003-3826-0484>), Thomas Brendan Murphy [ctb] (<https://orcid.org/0000-0002-5668-7046>), Michael Fop [ctb] (<https://orcid.org/0000-0003-3936-2757>)
Initial release
2022-05-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.