Description Usage Arguments Value Examples
EM algorithm for GMM estimation
1 | gmm_em(da, K, iter, stopping=1e-7, init, typ="G", add_eye="False")
|
da |
Data for clustering |
K |
Selected number of clusters |
iter |
Maximum iteration for EM algorithm |
stopping |
Stopping criterion |
init |
Initial values for EM |
typ |
CLEMM Type, "G": General CLEMM; "S": CLEMM-Shared |
add_eye |
Add 0.01*I_r to prevent S_k being too singular |
ll_seq |
Observed Log-likelihood sequence |
a |
Estimation of mixing weights |
muEst |
Estimation of clusters centers |
SigmaEst |
Estimation of clusters covariance |
iteration |
Number of iterations |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | set.seed(999)
K <- 3;r <- 15; u<- 1;N <- 1000;md=1
da <- data_generation(r, u, N, K, md)
pi0 <- c(0.3, 0.2, 0.5)
idx <- sample(1:K, N, replace = TRUE, prob = pi0)
dat <- matrix(NA, N, r)
for (j in 1:K) {
if(md <= 3){
x_tmp <- rmvnorm(sum(idx==j), mean = da$mu[, j], sigma = da$Sigma[, , j])
}else{ x_tmp <- rmvnorm(sum(idx==j), mean = da$mu[, j], sigma = da$Sigma)}
dat[idx==j, ] <- x_tmp
}
init=list()
init$centers = da$mu
init$wt = pi0
init$cov = da$Sigma
res_clemm = gmm_em(dat, K, iter=800, init=init)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.