# [R] R code for normal mixture EM algorithm

tj girlme80 at yahoo.com
Sat Mar 20 01:04:59 CET 2010

```Please help me in writing the R code for this problem. I've been solving this
for 4 days. It was hard for me to solve it. It's a simulation problem in R.

The problem is

My true model is a normal mixture which is given as
0.5 N(-0.8,1) + 0.5 N(0.8,1). This model has two components.

I will get a sample size equal to 100 from this model. I will do this 200
times.
That means, I will have 200 samples of size 100 each sample. Then for each
sample, I will estimate the parameters of this model using EM algorithm.

>From each samples generated, I need to fit a 1 component model, 2
components...... 5 components model. After that, I will try to evaluate AIC
and BIC and determine which of them have the correct choice. For example,
AIC has the correct choice if its minimum value occurred when we model two
components (Because the true model has two components). And then I need to
determine how many times AIC has the minimum value at component=2. I will
also do this for BIC.

Thank you!

~tj
--
View this message in context: http://n4.nabble.com/R-code-for-normal-mixture-EM-algorithm-tp1630181p1630181.html
Sent from the R help mailing list archive at Nabble.com.

```