[R] How to use "mix" to estimate the parameters for mixture gamma distribution?

Ben Bolker bolker at ufl.edu
Wed Jun 20 22:12:09 CEST 2007


Wang, Yun <ywang <at> med.wayne.edu> writes:

> 
> 
> Dear R users,
> 
> Please help me on using "mix" function under package "mixdist".
> 
> My data distribution shows there are two components for the mixture
distribution: left part is an
> exponential and right part is a normal. So I plan to use "gamma" mixture
distribution to estimate the
> parameters. Here is what I am using for the "mix" function.
> 
> Test<-mix(x, mixparam(mu=c(1,125),sigma=c(1,11.18)),"gamma") 
> 
> However, one error message shows up as:
> "Error in nlm(function(x) f(x, ...), p, hessian, typsize, fscale, msg,  :
missing value in parameter"
> 
> Does anybody know what that means and how to fix it to get the estimation?
Your help will be much appreciated.
> 
> Yun
> 

  You haven't given us enough to go on.  First of all,
mixdist is a contributed package -- not part of base R, and
not even on CRAN (but not too hard to find:
http://www.math.mcmaster.ca/peter/mix/mix.html ).  You might
consider asking the author/maintainer: see help(package="mixdist").

Second, please do as the posting guide suggests and give us
a simple, reproducible example.  If your data are small enough,
you can just post them, or post them to a web site and send
the URL -- or make up a small data set that also displays the
problem (you will often discover the answer for yourself in the
process of doing this!)

  Staring at the C code for nlm (in src/main/optimize.c) suggests
that nlm is being passed an NA in a parameter set somewhere -- you
might try options(error=recover) to start diagnosing, or change
print.level in your mix() call.

  But your best bet is to find a reproducible example for
us to look at.

  cheers
    Ben Bolker



More information about the R-help mailing list