# [R] Mixture of Univariate Normals

Ben Bolker ben at zoo.ufl.edu
Tue Oct 22 19:37:06 CEST 2002

```On Tue, 22 Oct 2002, Sharon Kuhlmann-Berenzon wrote:

>
> Dear list,
>
> Can anyone provide a package or code for estimating the parameters of a
> mixture of c (c >=2) univariate normal distributions?
>
> I've tried the algorithm provided by Venables & Ripley (1999) p 263, for
> the mixture of two normal, but I don't find the "ms" function in R. I've
> used nls instead, but I'm not sure if it works the same.

optim() is a closer analogue, but if you're assuming normal
distributions you should be able to reduce your problem to one that can be
handled by least-squares (nls).

See the on-line complements,
http://www.stats.ox.ac.uk/pub/MASS3/Compl.shtml, under chapter 8 the R
complements say:

Function nls is in standard package nls . Most of the optimization
examples can be done using nlm or optim , but symbolic differentiation
using deriv does not work for our examples. See the script ch08.R for
details.

> The data I have is very peaked and with long tails. It should be the
> mixture of two distributions (2 types of particles), possibly with the
> same mean or very similar means. The QQ plot using the results of the VR
> algorithm (above), however, still show a clear S shape. Could this mean
> that there is yet another normal distribution in the mixture, ie c=3?

Actually it sounds more like a mixture of t-distributions to me.  I'd
take a shot at modifying the VR algorithm accordingly.  (Although I would
note that if the means are very similar you may have some trouble
identifying the mixture ...)

> I've started the VR algorithm with different starting points, but they
> always converge to the same estimates.  I have about < 12000
> observations, and the VR algorithm converges after about 15 iterations.
>
> Thank you for any help.
>
>
> Sharon Kühlmann
>
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> SHARON KÜHLMANN-BERENZON
>
> Tel. +46-31-772 53 60			Dept. Mathematical Statistics
> Fax. +46-31-772 35 08			Chalmers University of Tech.
> e-mail: sharon at math.chalmers.se		Eklandagatan 86
> 					412 96 Göteborg, Sweden
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

--
318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```