4

I am trying to fit the negative binomial ditribution in R using the following code:

negfit <- fitdistr(Probhist$DemandQuantity,"negative binomial")
coef(negfit)

Data looks as below:

Probhist <- data.frame(
  DemandQuantity=rep(
    c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 17),
    c(8632, 2242, 707, 272, 132, 65, 32, 22, 12, 10, 1, 2, 2, 2, 1)
  )
)

When I run the fitdistr on above data, I get following warnings:

> negfit <- fitdistr(Probhist$DemandQuantity,"negative binomial")
Warning messages:
1: In densfun(x, parm[1], parm[2], ...) : NaNs produced
2: In densfun(x, parm[1], parm[2], ...) : NaNs produced
3: In densfun(x, parm[1], parm[2], ...) : NaNs produced
4: In densfun(x, parm[1], parm[2], ...) : NaNs produced
5: In densfun(x, parm[1], parm[2], ...) : NaNs produced
> coef(negfit)
     size        mu 
0.4692958 0.4911798 

In spite of the warnings, I do get the coefficient estimates. I am not able to understand if the output coeff values are trustworthy and can be used further. Also, what is the reason behind these warnings and how can I do away with them? Any help would be greatly appreciated.

Thanks.

Wraf
  • 747
  • 2
  • 10
  • 24
  • Here's a post I found on Google which suggests it is maybe nothing to be concerned about: http://r.789695.n4.nabble.com/Warnings-in-fitdistr-from-MASS-td850731.html – thelatemail Oct 02 '13 at 04:52
  • Thanks for providing the direction. I did some googling myself but never landed on this link. Seems like everything is fine and coeff values can be trusted. Thanks again. – Anurag Bhatnagar Oct 02 '13 at 05:04

0 Answers0