Re: [R] Rmix package and different distributions

From: Ben Bolker <>
Date: Sun 29 Oct 2006 - 19:44:08 GMT

nelson - <nelson1977 <at>> writes:

> hi all!
> i want to mix a dataset that is build up from 2 distribution: an
> exponential and a normal. I can' figure out how can i use Rmix package
> to do the fitting of my data. Pheraps it si the wrong package? any
> suggestion?
> thanks,
> nelson

  Perhaps use optim() or mle() [from the stats4 package] and a custom-defined negative log-likelihood function ...


nllfun <- function(p,a,mu,sigma) {

   -sum(log(p*dexp(x,a)+(1-p)*dnorm(x,mu,sigma))) }


[you'll need to provide starting values for the parameters]

  Please note that this is completely untested! See Venables and Ripley's mixture-modeling example in MASS for more details of this kind of custom fitting (their example is a mixture of two normals, but it should still be helpful)

  Ben Bolker mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon Oct 30 08:24:23 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 29 Oct 2006 - 22:30:15 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.