# [R] EM algorithm

From: eariasca <eariasca_at_math.ucsd.edu>
Date: Wed, 05 Mar 2008 13:50:34 -0800

Hi,

I am trying to understand how the functions em() and me() from the mclust package work. I cannot make sense of what the algorithm returns. Here is a basic, simple example:

```#########################################
```

# two bivariate normals, centered at (-5,0) and (5,0), with Id
covariance

x1 = cbind(rep(-5, 100), rep(0, 100)) + matrix(rnorm(100*2), 100, 2) x2 = cbind(rep(5, 100), rep(0, 100)) + matrix(rnorm(100*2), 100, 2) x = rbind(x1,x2)
plot(x[,1],x[,2])

library(mclust)

# start with equal chance of belonging to any of the two classes
out = me(modelName = 'EEE', data = x, z = 1/2*matrix(rep(1,200*2), 200, 2))
out\$parameters

# the algorithm does not recover the actual parameters!

```#########################################

```

In particular, each time the algorithm returns the same mean for both populations!

I also tried the em() function with an initialization given by mstep (), just as in the example in help(em).

Ery Arias-Castro

[[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 05 Mar 2008 - 22:41:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 05 Mar 2008 - 23:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.