# Pearson's residuals

A beginner's question about the Pearson's residual within the context of the chi-square test for goodness of fit:

As well as the test statistic, R's chisq.test function reports the Pearson's residual:

(obs - exp) / sqrt(exp)


I understand why looking at the raw difference between observed and expected values isn't that informative, as a smaller sample will result in a smaller difference. However, I'd like to know more about the effect of the denominator: why divide by the root of the expected value? Is this a 'standardized' residual?

• The denominator is used to account for the variance of raw residuals which then makes Pearson's residuals approximately of unit variance (there are other methods to achieve this). Please note that there's a component stdres for standardized residuals.
– chl
Dec 9 '12 at 10:57
• @chl Thank you for your quick response. However, I don't understand the concept of variance in this context. Do you know of any resources where I could learn more? I assume, then, that a Pearson's residual is not 'standardised', given that chisq.test also calculates the stdres component? Dec 9 '12 at 14:13
• The definitive reference to the analysis of categorical data is probably Categorical Data Analysis, by Alan Agresti. If nobody provides a more detailed answer, I will try to convert my comments to a proper answer.
– chl
Dec 9 '12 at 21:54
• Thanks for the link, @chl. I've access to the book, so will try to figure this one out myself. Dec 10 '12 at 22:54

The standard statistical model underlying analysis of contingency tables is to assume that (unconditional on the total count) the cell counts are independent Poisson random variables. So if you have an $$n \times m$$ contingency table, the statistical model used as a basis for analysis takes each cell count to have unconditional distribution:

$$X_{i,j} \text{ ~ Pois}(\mu_{i,j})$$

Once you impose a total cell count for the contingency table, or a row or column count, the resulting conditional distributions of the cell counts then become multinomial. In any case, for a Poisson distribution we have $$\mathbb{E}(X_{i,j}) = \mathbb{V}(X_{i,j}) = \mu_{i,j}$$, so the standardised cell count is:

$$\text{STD}(X_{i,j}) \equiv \frac{X_{i,j} - \mathbb{E}(X_{i,j})}{\sqrt{\mathbb{V}(X_{i,j})}} = \frac{X_{i,j} - \mu_{i,j}}{\sqrt{\mu_{i,j}}}$$

So, what you're seeing in the formula you are enquiring about, is the standardised cell count, under the assumption that the cell counts have an (unconditional) Poisson distribution.

From here it is common to test independence of the row and column variable in the data, and in this case you can use a test statistic that looks at the sum-of-squares of the above values (which is equivalent to the squared-norm of the vector of standardised values). The chi-squared test provides a p-value for this kind of test based on a large-sample approximation to the null distribution of the test statistic. It is usually applied in cases where none of the sell counts are too small.

In the context of goodness of fit, you may refer to this http://www.stat.yale.edu/Courses/1997-98/101/chigf.htm.

If you want to know how the denominator got there, you will have to view the chi-squared here as a normal approximation to the binomial, for starters, which then can be extended to multinomials.