Learn R Programming

pmclust (version 0.1-1)

em.step.worker: EM steps for workers

Description

The EM algorithm for model-based clustering of finite mixture Gaussian models with unstructured dispersions.

Usage

em.step.worker(PARAM.org)

Arguments

PARAM.org
an original set of parameters generated by set.global.

Value

  • A convergent results will be returned in the other list variables containing all new parameters which represent the components of models. See the help page of PARAM or PARAM.org for details.

Details

A global variable called X.worker should exist in the .GlobalEnv environment, usually the working environment. The X.worker is the data matrix to be clustered, and this matrix has a dimension N.worker by p.

A PARAM.org will be a local variable inside em.step.worker, and this variable is a list containing all parameters related to models. This function also updates in the parameters by the EM algorithm, and return the convergent results. The details of list elements are initially generated by set.global.

References

High Performance Statistical Computing Website: http://thirteen-01.stat.iastate.edu/snoweye/hpsc/

Dempster, A.P., Laird, N.M. and Rubin, D.B. (1977) Maximum Likelihood from Incomplete Data via the EM Algorithm, Journal of the Royal Statistical Society Series B, 39, 1-38.

See Also

set.global, mb.print, aecm.step.worker, apecm1.step.worker, apecm2.step.worker.

Examples

Run this code
# Save code in a file "demo.r" and run in 4 processors by
# > mpirun -np 4 Rscript demo.r

### Setup mpi environment.
library(Rmpi)
library(pmclust)
invisible(mpi.comm.dup(0, 1))

### Generate an example data.
N.allworkers <- rep(5000, mpi.comm.size())
N.worker <- 5000
N.K.worker <- c(2000, 3000)
N <- 5000 * mpi.comm.size()
p <- 2
K <- 2
seed <- 123 + mpi.comm.rank()
data.worker <- generate.basic.worker(N.allworkers, N.worker, N.K.worker,
                                     N, p, K, seed)
X.worker <- data.worker$X.worker

### Run clustering.
PARAM.org <- set.global(K = K)
# PARAM.org <- initial.em.worker(PARAM.org)
PARAM.org <- initial.RandEM.worker(PARAM.org)
PARAM.new <- em.step.worker(PARAM.org)
em.update.class.worker()
mb.print(PARAM.new, CHECK)

### Get results.
N.CLASS <- get.N.CLASS(K)
catmpi("# of class:", N.CLASS, "\n")

### Quit Rmpi.
mpi.quit()

Run the code above in your browser using DataLab