I am using the Ben bolker's R package "bbmle" to estimate the parameters of a binomial mixture distribution via Maximum Likelihood Method. For some data sets, I got the following warning messages: *Warning: optimization did not converge (code 1: ) There were 50 or more warnings (use warnings() to see the first 50)* Also, warnings() results the following: *In 0:(n - x) : numerical expression has 8 elements: only the first used 47: In beta(a, b) : NaNs produced* I would like to know whether this is a serious issue? if so.. how can I avoid it? thank you. -- View this message in context: http://r.789695.n4.nabble.com/bbmle-Warning-optimization-did-not-converge-tp4650730.html Sent from the R help mailing list archive at Nabble.com.

On Nov 25, 2012, at 1:52 PM, arun4 <arun.ganesh2012 at gmail.com> wrote:> I am using the Ben bolker's R package "bbmle" to estimate the parameters of a > binomial mixture distribution via Maximum Likelihood Method. For some data > sets, I got the following warning messages: > *Warning: optimization did not converge (code 1: ) > There were 50 or more warnings (use warnings() to see the first 50)* > Also, warnings() results the following: > *In 0:(n - x) : numerical expression has 8 elements: only the first used > 47: In beta(a, b) : NaNs produced* > > I would like to know whether this is a serious issue? if so.. how can I > avoid it? >Likely: can you make a reproducible example so we can diagnose? dput() is helpful for plaintext data transfer. Michael> thank you. > > > > -- > View this message in context: http://r.789695.n4.nabble.com/bbmle-Warning-optimization-did-not-converge-tp4650730.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.

Thank you Michael Weylandt. Let me to describe my problem fully, I have developed a new discrete probability distribution which has the following Probability mas function( as an alternative to binomial distribution) <http://r.789695.n4.nabble.com/file/n4650759/newdist.jpg> Where n= number of trials x are the binomial values a and b are the two parameters to be estimated (I use MLE method by calling mle2 from bbmle package) As you can see, there is an inner summation which runs from zero to (n-x) The below is the R functions I have written to define Negative Loglikelihood and estimate parameters: library(bbmle) * ###Define Negative LL Dist.NLL<-function(x,a,b,fre,n) { term<-0 for (j in 0:(n-x)) { term=term+(((-1)**j)*(choose(n-x,j))*(beta(((x/a)+1+(j/a)),b))) } density=b*choose(n,x)*term LL<-sum(fre*log(density)) return(-LL) } ##an example dataset x.values<-0:7 ##x values (here 7 trials) frequency<-c(47,54,43,40,40,41,39,95) ##Observed frequencies of x values ##Now use mle2 to estimate parameters. mle2(Dist.NLL, start=list(a=22,b=22), data=list(x=values ,fre=frequency, n=7)) * This is what I have done, bow I am getting "In 0:(n - x) : numerical expression has 8 elements: only the first used" error messages, which I afraid serious errors. Thanks again. -- View this message in context: http://r.789695.n4.nabble.com/bbmle-Warning-optimization-did-not-converge-tp4650730p4650759.html Sent from the R help mailing list archive at Nabble.com.

Sorry, x values are created as *values<- 0:7* -- View this message in context: http://r.789695.n4.nabble.com/bbmle-Warning-optimization-did-not-converge-tp4650730p4650761.html Sent from the R help mailing list archive at Nabble.com.

On 25.11.2012 19:44, arun4 wrote:> Thank you Michael Weylandt. > Let me to describe my problem fully, > I have developed a new discrete probability distribution which has the > following Probability mas function( as an alternative to binomial > distribution) > <http://r.789695.n4.nabble.com/file/n4650759/newdist.jpg> > > Where n= number of trials > x are the binomial values > a and b are the two parameters to be estimated (I use MLE method by calling > mle2 from bbmle package) > As you can see, there is an inner summation which runs from zero to (n-x) > > The below is the R functions I have written to define Negative Loglikelihood > and estimate parameters: > > library(bbmle) > > * ###Define Negative LL > Dist.NLL<-function(x,a,b,fre,n) { > term<-0 > for (j in 0:(n-x)) { > term=term+(((-1)**j)*(choose(n-x,j))*(beta(((x/a)+1+(j/a)),b))) > } > density=b*choose(n,x)*term > LL<-sum(fre*log(density)) > return(-LL) > } > > ##an example dataset > x.values<-0:7 ##x values (here 7 trials) > frequency<-c(47,54,43,40,40,41,39,95) ##Observed frequencies of x values > ##Now use mle2 to estimate parameters. > > mle2(Dist.NLL, start=list(a=22,b=22), data=list(x=values ,fre=frequency, > n=7)) > * > > This is what I have done, bow I am getting "In 0:(n - x) : numerical > expression has 8 elements: only the first used" error messages, which I > afraid serious errors.Dist.NLL obviously does not work for a vector of x values. You have to vectorize it. Uwe Ligges> > Thanks again. > > > > -- > View this message in context: http://r.789695.n4.nabble.com/bbmle-Warning-optimization-did-not-converge-tp4650730p4650759.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >