mxnormal {lazy.cluster} | R Documentation |
Fitting Finite Mixture of Normal Distributions
mxnormal(X, ncl, rho, mu, Sigma, maxiter = 100, eps = 1e-05, print = 0, debug = 0)
X |
Input data matrix: nobs x nvar |
ncl |
# of components to be mixed |
rho |
vector of mixing proportions |
mu |
ncl x nvar matrix of means |
Sigma |
nvar x nvar x ncl array of Dispersion matrices |
maxiter |
max # of iterations |
eps |
criterion for the relative improvement of lmlh |
print |
= 1 to print the result |
debug |
= 1 to print the intermediate result |
This function uses EM algorithm to estimate the parameters
of a finite mixture of ncl normal distribtuions.
The parameters, namely,
rho, mu and Sigma, must have the initial values.
A list of
rho: vector of mixing proportions
mu: ncl x nvar matrix of means
Sigma: nvar x nvar x ncl array of Dispersion matrices
lmlh: log marginal likelihood maximized
cluster: classification vector of observations
H: posterior probability matrix
# initial by kmeans ncl=2 # data=as.matrix(circle2[,1,drop=0]) data=circle2 resk=kmeans( data, ncl ) rho=resk$size/sum(resk$size) mu=resk$centers var=resk$tot.withinss/sum(resk$size) Disp=var*diag(ncol(mu)) Sigma=t(repmat(t(Disp),ncl)) dim(Sigma)=c(ncol(mu),ncol(mu),ncl) resm=mxnormal( data, ncl, rho, mu, Sigma, print=1 )