Dear All: I used optim() to minimise the loglikelihood function for fitting data to negative binomial distribution. But there initial value of log-likelihood and iteration 10 value are reasonable. for example: initial value 1451657.994524 iter 10 value 47297.534905 iter 20 value -623478636.8236478
Then the iter 20 vlaue suddelnly changes to a negative value and in the end the error mesage is "non finite finite different [13]" Has any one have this experience of what the wrong is? Thanks! Xin My function is: function (parameters,y,x1,x3) { alpha<-parameters[1:10]; beta<-parameters[11]; g<-parameters[12]; theta<-parameters[13]; j=x3 p=alpha[j]*(x1^beta)*exp(-g*x1) ifelse(x1>0, L<-lgamma(y+p)+p*log(theta)+y*(log(1-theta))-lfactorial(y)-lgamma(p) ,Inf) L } [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch 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.