You can compute the conditional probability that your variable equals k given
that it is non-zero. For example, if X has poisson distribution with parameter
lambda then
P(X=k/X!=0) = P(X=k)/(1-P(X=0)) = (exp(-lambda)/(1-exp(-lambda))*lambda^k/k!
Now you can find lambda for which the sum of squares of your errors is minimal
and then use CHi-aquared test using these expected frequencies.
Similarly for negative binomial distribution.
--- On Tue, 23/2/10, pinusan <anhong at msu.edu> wrote:
> From: pinusan <anhong at msu.edu>
> Subject: [R] Goodness of fit test for count data
> To: r-help at r-project.org
> Received: Tuesday, 23 February, 2010, 6:11 AM
>
> Dear? all,
>
> I am trying to test goodness of fit. I assume that a data
> follow Poisson or
> Negative binomial distribution. I can test the goodness of
> fit in case of no
> truncated data. However, I could not find any good function
> or packages when
> a data is truncated.?
>
> For example, a frequency table for the number of visiting
> emergency room in
> one hundred one observations past one year is as follow:
> N freq
> 1 30
> 2 35
> 3 26
> 4 8
> 5 0
> 6 2
> 7 0
>
> I expect the frequency table to satisfy a Poisson
> distribution or Negative
> binomial distribution. However, the distribution is
> different from the usual
> Poisson or Negative binomial distribution because one
> value, zero, is
> excluded. I expect that the distribution is zero truncated
> distribution.
>
> In case of SAS, I used NLMIXED procedure to calculate the
> expected
> probability when y=1 ? y=n under the assumption that a
> data follows Poisson
> or Negative binomial distribution. And then I run
> Chi-square test. If you
> need the SAS code, I will send E-mail.
> I want to run this test in R.
> Could you suggest any idea that can I perform this test in
> R.
>
> Have a nice day.
>
> --
> View this message in context:
http://n4.nabble.com/Goodness-of-fit-test-for-count-data-tp1564963p1564963.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org
> 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.
>