﻿ Contingency tables > Chi-square contingency table test

# Chi-square contingency table test

Navigation:  Contingency tables >

# Chi-square contingency table test

The standard chi-square contingency table test is applied to counts of events classified by two or more characteristics arranged as a cross-classification table of r rows and c columns. The standard form of such a table is shown below. Cell entries for row i, column j are counts, nij, and the row, column and total sums are indicated by a dot where summation is over that subscript. Similar tables can be constructed for 3 or more dimensions, but this form of analysis is less common.

 Characteristic B Total 1 2 .... c A 1 n11 n12 n1c n1. 2 n21 n22 n2c n2. 3 ... r nr1 nr2 nrc nr. Total n.1 n.2 n.c n..

The chi-square test statistic is essentially the same as we applied in the goodness-of-fit section, thus it compares the observed frequency distribution in each cell of the sample, O, with the expected frequency distribution, E, in this case derived from the marginal probabilities on the assumption that the characteristics are independent. The difference between the observed and expected values for each cell (O-E) is squared to remove negative signs, and then standardized by the expected frequency in order to obtain a standardized measure of the difference. The sum of these standardized differences is then calculated and compared to a chi-square distribution with (r-1)(c-1) degrees of freedom: As with the goodness-of-fit test, there is a requirement that no cell entries are less than 4 or 5 in order for the chi-square approximation to be acceptable. For 2x2, rx2 and cx2 tables combining rows or columns to ensure all cell entries are 5+ is generally not possible or desirable and for similar cases an exact test rather than the chi-square test should be used. In the past a correction suggested by Yates (and known as Yates correction) was often applied when calculating probabilities for 2x2 tables, but the correction is not generally satisfactory and it is preferable to use the exact method in such cases, particularly as it is now readily available in most computer packages.

Example: Childhood nutrition and intelligence test (IQ test) results

This example, reported in Bradford Hill (1937, [BRA1]), is based on an analysis published in 1936 of 950 schoolchildren in the UK. The data table is shown below:

 Characteristic B: Intelligence quotients (IQ scores) Total <80% 80-89% 90-99% 100%+ A: Nutrition level Satisfactory 245 228 177 219 869 Unsatisfactory 31 27 13 10 81 Total 276 255 190 229 950

The expected value for cell 1 (row 1 column 1) is 869x276/950=252.5, and for each cell a similar calculation can be carried out. Computing the terms of the statistic using these values produces an overall measure of 9.75 (Bradford Hill reported the figure as 10.37, but this is incorrect as he used very roughly rounded figures in his calculation). There are two rows and four columns, so the degrees of freedom (df) are 1x3=3. The critical value for the chi-square distribution with df=3 at the 5% level is 7.81, which suggests that the observed pattern is significant, i.e. it is unlikely to have arisen simply by chance, and perhaps their is a relationship between the nutrition that children receive and their educational attainment... but understanding the nature of this possible relationship is an entirely different matter. It might be the case, for example, that children with poor nutrition have been brought up in an environment that is not conducive to educational development, and that these factors are of much greater importance than nutrition, and the question as to whether IQ tests are an appropriate form of measurement is also clearly important.

This kind of analysis can be carried out in a spreadsheet very simply, or using functionality provided in most statistical software packages. For example, the R function chisq.test(x,correct=F) will perform the computation directly from an input matrix, x. The option correct=F ensures that Yates correction is not applied in the case of small values. In this example no correction would be applied in any case, and the estimated significance level is given as p=0.0208, whereas with the exact test the significance (typically reserved for 2x2 tables) is given as p=0.01648, i.e. very comparable results. Cramers V measure of association in this example is 0.1, suggesting that whilst the association is significant it is not particularly strong.

References

[BRA1] Bradford Hill A (1937) Principles of Medical Statistics. The Lancet, London (issued in various editions until 1971. Then republished as "A Short Textbook of Medical Statistics" in 1977