## Generate a random matrix of counts
counts <- matrix(rPT(n=2000, a=0.5, mu=10, D=5), nrow=20)
## Perform the goodness-of-fit tests for every row in the matrix
chi2gof <- gofTest(counts)
## Calculate and sort the corresponding P-values for the
## null hypothesis that counts follow a negative binomial distribution
sort(pchisq(chi2gof, df=1, lower.tail=FALSE))
Run the code above in your browser using DataLab