Mclust: Model-Based Clustering

Description Usage Arguments Value References See Also Examples

View source: R/mclust.R

Description

The optimal model according to BIC for EM initialized by hierarchical clustering for parameterized Gaussian mixture models.

Usage

1
2
3
4
5
6
7
Mclust(data, G = NULL, modelNames = NULL, 
       prior = NULL, 
       control = emControl(), 
       initialization = NULL, 
       warn = mclust.options("warn"), 
       x =  NULL, 
       verbose = interactive(), ...)

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.

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 default is:

for univariate data c("E", "V")
for multivariate data (n > d) mclust.options("emModelNames")
for multivariate data (n <= d) the spherical and diagonal models c("EII", "VII", "EEI", "EVI", "VEI", "VVI")

The help file for mclustModelNames describes the available models.

prior

The default assumes no prior, but this argument allows specification of a conjugate prior on the means and variances through the function priorControl.
Note that, as described in defaultPrior, in the multivariate case only 10 out of 14 models may be used in conjunction with a prior, i.e. those available in MCLUST up to version 4.4.

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. For multivariate data, the default is to compute a hierarchical clustering tree by applying function hc with modelName = "VVV" to the data or a subset as indicated by the subset argument. The hierarchical clustering results are to start EM. For univariate data, the default is to use quantiles to start EM.

subset

A logical or numeric vector specifying a subset of the data to be used in the initial hierarchical clustering phase. By default no subset is used unless the number of observations exceeds the value specified by mclust.options("subset"). Note that to guarantee exact reproducibility of results a seed must be specified (see set.seed).

noise

A logical or numeric vector indicating an initial guess as to which observations are noise in the data. If numeric the entries should correspond to row indexes of the data. If supplied, a noise term will be added to the model in the estimation.

warn

A logical value indicating whether or not certain warnings (usually related to singularity) should be issued. The default is controlled by mclust.options.

x

An object of class 'mclustBIC'. If supplied, BIC values for models that have already been computed and are available in x are not recomputed. All arguments, with the exception of data, G and modelName, are ignored and their values are set as specified in the attributes of x. Defaults for G and modelNames are taken from x.

verbose

A logical controlling if a text progress bar is displayed during the fitting procedure. By default is TRUE if the session is interactive, and FALSE otherwise..

...

Catches unused arguments in indirect or list calls via do.call.

Value

An object of class 'Mclust' providing the optimal (according to BIC) mixture model estimation.

The details of the output components are as follows:

call

The matched call

data

The input data matrix.

modelName

A character string denoting the model at which the optimal BIC occurs.

n

The number of observations in the data.

d

The dimension of the data.

G

The optimal number of mixture components.

BIC

All BIC values.

bic

Optimal BIC value.

loglik

The log-likelihood corresponding to the optimal BIC.

df

The number of estimated parameters.

hypvol

The hypervolume parameter for the noise component if required, otherwise set to NULL (see hypvol).

parameters

A list with the following components:

pro

A vector whose kth component is the mixing proportion for the kth component of the mixture model. If missing, equal proportions are assumed.

mean

The mean for each component. If there is more than one component, this is a matrix whose kth column is the mean of the kth component of the mixture model.

variance

A list of variance parameters for the model. The components of this list depend on the model specification. See the help file for mclustVariance for details.

z

A matrix whose [i,k]th entry is the probability that observation i in the test data belongs to the kth class.

classification

The classification corresponding to z, i.e. map(z).

uncertainty

The uncertainty associated with the classification.

References

Scrucca L., Fop M., Murphy T. B. and Raftery A. E. (2016) mclust 5: clustering, classification and density estimation using Gaussian finite mixture models, The R Journal, 8/1, pp. 205-233.

Fraley C. and Raftery A. E. (2002) Model-based clustering, discriminant analysis and density estimation, Journal of the American Statistical Association, 97/458, pp. 611-631.

Fraley C., Raftery A. E., Murphy T. B. and Scrucca L. (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.

C. Fraley and A. E. Raftery (2007) Bayesian regularization for normal mixture estimation and model-based clustering. Journal of Classification, 24, 155-181.

See Also

summary.Mclust, plot.Mclust, priorControl, emControl, hc, mclustBIC, mclustModelNames, mclust.options

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
mod1 <- Mclust(iris[,1:4])
summary(mod1)

mod2 <- Mclust(iris[,1:4], G = 3)
summary(mod2, parameters = TRUE)

# Using prior
mod3 <- Mclust(iris[,1:4], prior = priorControl())
summary(mod3)

mod4 <- Mclust(iris[,1:4], prior = priorControl(functionName="defaultPrior", shrinkage=0.1))
summary(mod4)

# Clustering of faithful data with some artificial noise added 
nNoise <- 100
set.seed(0) # to make it reproducible
Noise <- apply(faithful, 2, function(x) 
                            runif(nNoise, min = min(x)-.1, max = max(x)+.1))
data <- rbind(faithful, Noise)
plot(faithful)
points(Noise, pch = 20, cex = 0.5, col = "lightgrey")
set.seed(0)
NoiseInit <- sample(c(TRUE,FALSE), size = nrow(faithful)+nNoise, 
                    replace = TRUE, prob = c(3,1)/4)
mod5 <- Mclust(data, initialization = list(noise = NoiseInit))
summary(mod5, parameter = TRUE)
plot(mod5, what = "classification")

Example output

Package 'mclust' version 5.3
Type 'citation("mclust")' for citing this R package in publications.
----------------------------------------------------
Gaussian finite mixture model fitted by EM algorithm 
----------------------------------------------------

Mclust VEV (ellipsoidal, equal shape) model with 2 components:

 log.likelihood   n df       BIC       ICL
       -215.726 150 26 -561.7285 -561.7289

Clustering table:
  1   2 
 50 100 
----------------------------------------------------
Gaussian finite mixture model fitted by EM algorithm 
----------------------------------------------------

Mclust VEV (ellipsoidal, equal shape) model with 3 components:

 log.likelihood   n df       BIC       ICL
      -186.0736 150 38 -562.5514 -566.4577

Clustering table:
 1  2  3 
50 45 55 

Mixing probabilities:
        1         2         3 
0.3333333 0.3003844 0.3662823 

Means:
              [,1]     [,2]     [,3]
Sepal.Length 5.006 5.914879 6.546670
Sepal.Width  3.428 2.777504 2.949495
Petal.Length 1.462 4.203758 5.481901
Petal.Width  0.246 1.298819 1.985322

Variances:
[,,1]
             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length   0.13322911  0.10940214  0.019196013 0.011587928
Sepal.Width    0.10940214  0.15497824  0.012098300 0.010011682
Petal.Length   0.01919601  0.01209830  0.028276976 0.005819438
Petal.Width    0.01158793  0.01001168  0.005819438 0.010693650
[,,2]
             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length   0.22561867  0.07613421   0.14679059  0.04331622
Sepal.Width    0.07613421  0.08020281   0.07370230  0.03435034
Petal.Length   0.14679059  0.07370230   0.16601076  0.04947014
Petal.Width    0.04331622  0.03435034   0.04947014  0.03335458
[,,3]
             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length   0.42946303  0.10788462   0.33465810  0.06547643
Sepal.Width    0.10788462  0.11602293   0.08918583  0.06141314
Petal.Length   0.33465810  0.08918583   0.36451484  0.08724485
Petal.Width    0.06547643  0.06141314   0.08724485  0.08671670
Warning message:
In mclustBIC(data = c(5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.6, 5, 4.4, 4.9,  :
  The presence of BIC values equal to NA is likely due to one or more of the mixture proportions being estimated as zero, so that the model estimated reduces to one with a smaller number of components.
----------------------------------------------------
Gaussian finite mixture model fitted by EM algorithm 
----------------------------------------------------

Mclust VEV (ellipsoidal, equal shape) model with 2 components:

Prior: defaultPrior()

 log.likelihood   n df       BIC      ICL
      -225.2685 150 26 -580.8136 -580.814

Clustering table:
  1   2 
 50 100 
Warning message:
In mclustBIC(data = c(5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.6, 5, 4.4, 4.9,  :
  The presence of BIC values equal to NA is likely due to one or more of the mixture proportions being estimated as zero, so that the model estimated reduces to one with a smaller number of components.
----------------------------------------------------
Gaussian finite mixture model fitted by EM algorithm 
----------------------------------------------------

Mclust VEV (ellipsoidal, equal shape) model with 2 components:

Prior: defaultPrior(shrinkage = 0.1)

 log.likelihood   n df       BIC       ICL
      -227.6729 150 26 -585.6223 -585.6227

Clustering table:
  1   2 
 50 100 
----------------------------------------------------
Gaussian finite mixture model fitted by EM algorithm 
----------------------------------------------------

Mclust EEI (diagonal, equal volume and shape) model with 3 components
and a noise term:

 log.likelihood   n df       BIC       ICL
      -1745.593 372 12 -3562.212 -3705.656

Clustering table:
  1   2   3   0 
114  90  61 107 

Mixing probabilities:
        1         2         3         0 
0.2700585 0.2117591 0.1527994 0.3653829 

Means:
               [,1]      [,2]      [,3]
eruptions  4.533053  1.970887  4.005379
waiting   81.158803 53.768947 78.296247

Variances:
[,,1]
           eruptions  waiting
eruptions 0.04217089  0.00000
waiting   0.00000000 26.90826
[,,2]
           eruptions  waiting
eruptions 0.04217089  0.00000
waiting   0.00000000 26.90826
[,,3]
           eruptions  waiting
eruptions 0.04217089  0.00000
waiting   0.00000000 26.90826

Hypervolume of noise component:
191.8869 

mclust documentation built on July 2, 2018, 9:03 a.m.