[R] Goodness of fit to Poisson / NegBinomial

Jim Lindsey james.lindsey at luc.ac.be
Wed Feb 7 10:55:27 CET 2001


> 
> All,
> 
> I have some data on parasites on apple leaves and want to do a
> goodness of fit test to a Poisson distribution. This seems to
> do it:
> 
>   mites <- c(rep(0,70),
>              rep(1,38),
>              rep(2,17), 
>              rep(3,10), 
>              rep(4,9), 
>              rep(5,3), 
>              rep(6,2), 
>              rep(7,1))
> 
>   tab <- table(mites)
>   NSU <- length(mites)
>   N <- sum(mites)
>   NSU.Mean <- N / NSU
>   exp <- dpois(as.numeric(dimnames(tab)[[1]]), NSU.Mean) *  NSU
>   chi2 <- sum(((as.vector(tab) - exp)^2) / exp)
> 
>   tab
>   exp
>   chi2
>   
> I have some small expected values and so need to collapse some
> categories. If anyone has code to do that already ... but my
> question is how would I do the same for a negative binomial
> distribution?

The negative binomial density function is available in my rmutil
library. (www.luc.ac.be/~jlindsey/rcode.html)
  Jim

> 
> Mark
> 
> --
> Mark Myatt
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list