Skip to content

Commit 900b883

Browse files
committed
Add e.step before em.step call
1 parent 74b9bcd commit 900b883

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

R/00_pmclust_reduceK.r

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ pmclust.reduceK <- function(X = NULL, K = 2, MU = NULL,
44
algorithm = .PMC.CT$algorithm, RndEM.iter = .PMC.CT$RndEM.iter,
55
CONTROL = .PMC.CT$CONTROL, method.own.X = .PMC.CT$method.own.X,
66
rank.own.X = .pbd_env$SPMD.CT$rank.source, comm = .pbd_env$SPMD.CT$comm){
7+
if(algorithm[1] == "kmeans"){
8+
stop("kmeans/pkmeans is not supported in reduceK.")
9+
}
10+
711
### Run through original pmclust().
812
ret <- pmclust(X = X, K = K, MU = MU, algorithm = algorithm,
913
RndEM.iter = RndEM.iter, CONTROL = CONTROL,
@@ -43,22 +47,25 @@ pmclust.reduceK <- function(X = NULL, K = 2, MU = NULL,
4347
PARAM.org$MU <- matrix(PARAM.new$MU[, -i.k], ncol = K)
4448
PARAM.org$SIGMA <- PARAM.new$SIGMA[-i.k]
4549

50+
if(algorithm[1] %in% .PMC.CT$algorithm.gbd){
51+
e.step.spmd(PARAM.org)
52+
} else if(algorithm[1] %in% .PMC.CT$algorithm.dmat){
53+
e.step.dmat(PARAM.org)
54+
} else{
55+
comm.stop("The algorithm is not found.")
56+
}
57+
4658
# Update steps.
4759
method.step <- switch(algorithm[1],
4860
"em" = em.step,
4961
"aecm" = aecm.step,
5062
"apecm" = apecm.step,
5163
"apecma" = apecma.step,
52-
"kmeans" = kmeans.step,
5364
NULL)
5465
PARAM.new <- method.step(PARAM.org)
5566

5667
# Obtain classifications.
57-
if(algorithm[1] == "kmeans"){
58-
kmeans.update.class()
59-
} else{
60-
em.update.class()
61-
}
68+
em.update.class()
6269

6370
# Get class numbers.
6471
if(algorithm[1] %in% .PMC.CT$algorithm.gbd){

0 commit comments

Comments
 (0)