[R] Rmix package and different distributions
Ben Bolker
bolker at zoo.ufl.edu
Sun Oct 29 20:44:08 CET 2006
nelson - <nelson1977 <at> gmail.com> 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 ...
e.g.
nllfun <- function(p,a,mu,sigma) {
-sum(log(p*dexp(x,a)+(1-p)*dnorm(x,mu,sigma)))
}
mle(minuslogl=nllfun,...)
[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
More information about the R-help
mailing list