[R] fitting a mixed exponential distribution

Ben Bolker bolker at zoo.ufl.edu
Mon Mar 12 15:43:13 CET 2007


Vishal Mehta <vishalm1975 <at> gmail.com> writes:

> Also, i thought of formulating the likelihood function and using mle()
> in package stats4-- but had trouble writing down the likelihood
> function for the case of a mixed exponential distribution...


  I don't know offhand if there are CRAN packages etc. that
will do this -- but the canonical example is the model in MASS
for Old Faithful eruptions, which is a mixture model coded by
hand -- I believe it's a normal mixture model but it should
be a good starting point for rolling your own.

   The mixture model log-likelihood would look something like this:

mixexplik <- function(p,lambda1,lambda2) {
  log(p*dexp(x,lambda1) + (1-p)*dexp(x,lambda2))
}

  good luck,
    Ben Bolker



More information about the R-help mailing list