Question

Matlab contains the following function:

obj = gmdistribution.fit(X,k)

As shown on this website.

Is there an R package that offers this functionality as well?

Was it helpful?

Solution 2

The MClust package contains the function densityMclust which produces an object that contains parameter estimates for the fitted Gaussian mixture model along with the density itself. From the MClust manual:

> densWaiting <- densityMclust(faithful$waiting)
> summary(densWaiting, parameters = TRUE)
-------------------------------------------------------
Density estimation via Gaussian finite mixture modeling
-------------------------------------------------------
Mclust E (univariate, equal variance) model with 2 components:
log.likelihood
n df
BIC
-1034 272 4 -2090.4
Clustering table:
1   2
99 173
Mixing probabilities:
1    2
0.36102 0.63898
Means:
1    2
54.619 80.094
Variances:
1    2
34.439 34.439
 A two-components mixture of Gaussian variables with the same variance is selected by BIC. The
parameter estimates can be read from the summary output.
A plot of density estimate can be obtained using the corresponding plot method:

> plot(densWaiting)    The density can also be plotted together with a histogram of the observed data by using the optional
argument data:
> plot(densWaiting, data = faithful$waiting)

OTHER TIPS

See if the EMCluster package suits your needs.

 install.packages("EMCluster")

 # excerpt from pg 12 of the EMCluster manual.
 library(EMCluster, quiet = TRUE)
 set.seed(1234)
 x <- da1$da
 ret.em <- init.EM(x, nclass = 2, method = "em.EM")
 plotem(ret.em, x)

If not, there's other Model-based clustering methods in R. Enjoy!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top