2014-04-02 92 views

回答

1

MClust包中包含函數densityMclust,該函數生成一個對象,該對象包含擬合高斯混合模型的參數估計以及密度本身。從MClust手冊:

> 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) 
2

看看EMCluster包是否適合您的需求。

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) 

如果不是,那麼R中有另一個Model-based clustering methods。享受!