# Expected Counts in Pearson's Goodness of Fit Test

A Common expression for Pearson's goodness of fit test is

$\chi^2 = \sum_i \frac{(O_i - E_i)^2}{E_i}$

Where $O_i$ and $E_i$ are the observed and expected frequencies respectively.

Now assuming we want to test the goodness-of-fit of a Poisson distribution to the data, estimated using a MLE parameter from the same data.

Resources on the internet claim that expected frequencies for each cell can be calculated by $E_i = np_i$, where $p_i = P(X_i=O_i|\lambda)$ is the probability of observing $O_i$ calculated from the poisson distribution with parameter $\lambda$, and $n$ is the total count.

This is what seems odd to me. Surely, if our cells were truly distributed under Poisson distribution the expected counts would be $E_i = E[X_i] = \lambda$.

Is there a reason why we need to treat each cells as a binomial random variable, as it seems to be indicated, rather than a RV under the true distribution?

• If you condition on the observed count, $n$, the expected number in each cell is the probability of being in the cell times $n$. – Glen_b -Reinstate Monica Jan 4 '14 at 22:20

Think about the implications of your suggestion. If $E_i = E[X_i] = \lambda$, then the expected count for every possible $X_i$ would be the same (namely $\lambda$). That would be a uniform distribution, not a Poisson. In addition, note that the support for the Poisson distribution is $[0, +\!\infty]$; thus, if you 'expect' (I recognize I'm being very sloppy with my terminology here) $\lambda$ realizations of each value, your sample size would be $\lambda\times\infty=\infty$. I think these considerations ought to be enough to establish the idea that the expected count for a given possible value, $X_i$, cannot be $\lambda$.
As for why the distribution of observed counts at a given value, $X_i$, distributed as a binomial, remember that your sample is finite. Since the probability mass at each possible value is given by the Poisson's pmf, each observation can be understood as the outcome of a Bernoulli trial (i.e., that particular $X_i$ was observed or it wasn't). With $n$ such Bernoulli trials, the number of observations at each possible value will be distributed as a binomial. Therefore, because the number of observations of each possible value that are realized in your sample is binomial, the formula for the expectation of the relevant binomial distribution is the formula to use to calculate the expectation for that specific value.
• Okay, I think I now get where the point of my confusion was. I was under impression that the expression sums over the observations in the sample, rather than different values of $X_i$ you could obtain. In that case, it would be perfectly acceptable to use $\lambda$ for expectation. Provided that we indeed sum over the counts of values $X_i$ could obtain, and not the $X_i$s themselves, Binomial makes much more sense then. Thanks! – Saulius Lukauskas Jan 4 '14 at 22:34
• I did not follow the logic in the first paragraph: none of the properties of a Poisson distribution you mention would imply $\lambda$ cannot be an expected count. Another puzzling aspect of this answer is that it does not appear to match the actual use of the Poisson distribution in the document referenced by the O.P. The context concerns using a $\chi^2$ test to assess whether a dataset can be modeled by a Poisson distribution whereas this answer--if I read it correctly--seems to address the sampling distribution of the values in the dataset, which is a different issue. – whuber Jan 4 '14 at 23:08