Learn R Programming

mclust (version 5.3)

densityMclust: Density Estimation via Model-Based Clustering

Description

Produces a density estimate for each data point using a Gaussian finite mixture model from Mclust.

Usage

densityMclust(data, …)

Arguments

data

A numeric vector, matrix, or data frame of observations. Categorical variables are not allowed. If a matrix or data frame, rows correspond to observations and columns correspond to variables.

Additional arguments for the Mclust function. In particular, setting the arguments G and modelNames allow to specify the number of mixture components and the type of model to be fitted. By default an "optimal" model is selected based on the BIC criterion.

Value

An object of class densityMclust, which inherits from Mclust, is returned with the following slot added:

density

The density evaluated at the input data computed from the estimated model.

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

plot.densityMclust, Mclust, summary.Mclust, predict.densityMclust.

Examples

Run this code
# NOT RUN {
dens = densityMclust(faithful$waiting)
summary(dens)
summary(dens, parameters = TRUE)
plot(dens, what = "BIC", legendArgs = list(x = "topright"))
plot(dens, what = "density", data = faithful$waiting)

dens = densityMclust(faithful)
summary(dens)
summary(dens, parameters = TRUE)
plot(dens, what = "density", data = faithful)
plot(dens, what = "density", data = faithful,
     drawlabels = FALSE, points.pch = 20, col = "grey", 
     levels = quantile(dens$density, probs = c(0.05, 0.25, 0.5, 0.75, 0.95)))
plot(dens, what = "density", type = "image", col = topo.colors(50))
plot(dens, what = "density", type = "persp")

dens = densityMclust(iris[,1:4])
summary(dens, parameters = TRUE)
plot(dens, what = "density", data = iris[,1:4], 
     col = "slategrey", drawlabels = FALSE, nlevels = 7)
# }
# NOT RUN {
  plot(dens, what = "density", type = "image", col = "slategrey")
  plot(dens, what = "density", type = "persp", col = grey(0.9))
# }

Run the code above in your browser using DataLab