[R] Fitting Mixture distributions

Aanchal Sharma
Wed, 07 Sep 2016 22:51:22 -0000

Hi Simon

I am facing same problem as described above. i am trying to fit gaussian
mixture model to my data using normalmixEM. I am running a Rscript which
has this function running as part of it for about 17000 datasets (in loop).
The script runs fine for some datasets, but it terminates when it
encounters one dataset with the following error:

Error in normalmixEM(expr_glm_residuals, lambda = c(0.75, 0.25), k = 2,  :
  Too many tries!

(command used: expr_mix_gau <- normalmixEM(expr_glm_residuals, lambda =
c(0.75,0.25), k = 2, epsilon = 1e-08, maxit = 10000, maxrestarts=200, verb
= TRUE))
(expr_glm_residuals is my dataset which has residual values for different
samples)

It is suggested that one should define the mu and sigma in the command by
looking at your dataset. But in my case there are many datasets and it will
keep on changing every time. please suggest what can I do to resolve this
issue.

Regards
Anchal

On Tuesday, 16 July 2013 17:53:09 UTC-4, Simon Zehnder
wrote:
>
> Hi Tjun Kiat Teo,
>
> you try to fit a Normal mixture to some data. The Normal mixture is very
> delicate when it comes to parameter search: If the variance gets closer and
> closer to zero, the log Likelihood becomes larger and larger for any values
> of the remaining parameters. Furthermore for the EM algorithm it is known,
> that it takes sometimes very long until convergence is reached.
>
> Try the following:
>
> Use as starting values for the component parameters:
>
> start.par <- mean(your.data, na.rm = TRUE) + sd(your.data, na.rm = TRUE)
*
> runif(K)
>
> For the weights just use either 1/K or the R cluster function with K
> clusters
>
> Here K is the number of components. Further enlarge the maximum number of
> iterations. What you could also try is to randomize start parameters and
> run an SEM (Stochastic EM). In my opinion the better method is in this case
> a Bayesian method: MCMC.
>
>
> Best
>
> Simon
>
>
> On Jul 16, 2013, at 10:59 PM, Tjun Kiat Teo <teot... at gmail.com
> <javascript:>> wrote:
>
> > I was trying to use the normixEM in mixtools and I got this error
> message.
> >
> > And I got this error message
> >
> > One of the variances is going to zero;  trying new starting values.
> > Error in normalmixEM(as.matrix(temp[[gc]][, -(f + 1)])) : Too many
> tries!
> >
> > Are there any other packages for fitting mixture distributions  ?
> >
> >
> > Tjun Kiat Teo
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-h... at r-project.org <javascript:> 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.
>
> ______________________________________________
> R-h... at r-project.org <javascript:> 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.
>