Wang, Yun
2007-Jun-20 18:40 UTC
[R] How to use "mix" to estimate the parameters for mixture gamma distribution?
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 =============================================Yun Wang Research Assistant Department of Family Medicine and Public Health Sciences Wayne State University School of Medicine 177 Shiffman Library 4325 Brush Detroit, MI 48201 Phone: 313-577-0707 Fax: 313-577-1773 ============================================= [[alternative HTML version deleted]]
Ben Bolker
2007-Jun-20 20:12 UTC
[R] How to use "mix" to estimate the parameters for mixture gamma distribution?
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 mixturedistribution: left part is an> exponential and right part is a normal. So I plan to use "gamma" mixturedistribution 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