## Generate two Gaussian normal distributions
## and do not produce plots
mu1 = c(1,2)
sigma1 = matrix(c(2, 0, 0, .5), nrow=2, byrow=TRUE) #[2 0; 0 .5];
mu2 = c(-3, -5)
sigma2 = matrix(c(1, 0, 0, 1), nrow=2, byrow=TRUE)
n1 = 100
n2 = 200
Y = rbind(MASS::mvrnorm(n1, mu1, sigma1),
MASS::mvrnorm(n2, mu2, sigma2))
k = 2
pi = c(1/3, 2/3)
mu = rbind(mu1, mu2)
sigma = array(0, dim=c(2,2,2))
sigma[,,1] = sigma1
sigma[,,2] = sigma2
ll = matrix(0, nrow=n1+n2, ncol=2)
for(j in 1:k)
ll[,j] = log(pi[j]) + tclust:::dmvnrm(Y, mu[j,], sigma[,,j])
dd = tclust:::estepRR(ll)
dd$obj
dd$logpdf
dd$postprob
Run the code above in your browser using DataLab