Learn R Programming

pmclust (version 0.1-1)

aecm.step.worker: AECM steps for workers

Description

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

Usage

aecm.step.worker(PARAM.org)

Arguments

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

Value

  • A convergent results will be returned the other list variable 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 aecm.step.worker, and this variable is a list containing all parameters related to models. This function also updates in the parameters by the AECM 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/

Meng, X.-L. and Van Dyk, D. (1997) The EM Algorithm.an Old Folk-song Sung to a Fast New Tune, Journal of the Royal Statistical Society Series B, 59, 511-567.

See Also

set.global, mb.print, em.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 <- aecm.step.worker(PARAM.org)
em.update.class.worker()

### 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