[R] how to estimate parameters of multimodal distribution
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Apr 10 12:42:40 CEST 2003
Package mclust is all about fitting mixtures of normal distributions to
data.
It's not as easy as some people make out, since there can be many good
fits with very different sets of parameters -- I would run the procedures
in mclust several times from different starting points.
On Thu, 10 Apr 2003, Petr Pikal wrote:
> Dear all
>
> Please, is there any function or package for dealing with multimodal distributions?
> I try to fit multimodal distribution or more precisely to find out mixture of normal
> distributions which can lead to my actual data.
>
> I use optim to find (in that case) two parameters but what I want is to let the
> function find out arbitrary number of normal distributions underlaying my actual
> data and estimate all parameters automatically. Actually I want to elaborate some
> function which is similar to procedures used for evaluating DTA, IR or XRD
> spectra. Is the optim way suitable for this task?
>
> I would be gratefull for **any** hint.
>
> Here is some artificial example.
>
> # making two normals and putting them together
>
> x<-seq(5,100,5)
> y1<-abs(dnorm(x,30,5)+rnorm(20,0,.002))
> y2<-abs(dnorm(x,60,10)+rnorm(20,0,.002))
> y<-y1+y2
> y<-y/sum(y)*100
>
> # *** my data actually look like this***
> n<-round(y/sum(y)*100)
>
> opt<-optim(c(5,10),fff)
> matplot(x,cbind(y,fff2(c(5.3,10))),type="l")
>
> # quite OK but I need a little bit more general solution
>
> fff<-function(p)
> {
> p1<-p[1]
> p2<-p[2]
> v<-dnorm(x,30,p1)+dnorm(x,60,p2)
> s<-sum(v)
> sum((y-v/s)^2)
> }
>
> fff2<-function(p)
> {
> p1<-p[1]
> p2<-p[2]
> v<-dnorm(x,30,p1)+dnorm(x,60,p2)
> s<-sum(v)
> v/s
> }
>
> Thank you very much for any help.
> Best regards.
>
> Petr Pikal
> petr.pikal at precheza.cz
> p.pik at volny.cz
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list