Displaying 1 result from an estimated 1 matches for "mixnbinom".
2007 Oct 23
1
How to avoid the NaN errors in dnbinom?
...(x, size, prob, log) : NaNs produced
I know from the help files that for dnbinom "Invalid size or prob will
result in return value NaN, with a warning", but I am not able to find a
workaround for this in my code to avoid it. I appreciate the help. Thanks.
Below is the reproducible code:
mixnbinom=function(y,k1,mu1,k2,mu2,prob,eps=
1/100000){
new.parms=c(k1,mu1,k2,mu2,prob)
err=1
iter=1
maxiter=100
hist(y,probability=T,nclass=30,col="lightgrey",main="The EM algorithm")
xvals=seq(min(y),max(y),1)
lines(xvals,prob*dnbinom(xvals,size=k1,mu=mu1)+
(1-prob)*dnbinom(xvals,size=k...