Categorical × categorical
Does the distribution of one variable change across the categories of the other? χ², contingency coefficient C and coefficient T
Chi-squared (χ²)
Contingency coefficient (C)
Coefficient T
- Base of the percentages: row and column percentages answer different questions. "What share of college graduates use the internet" is not the same as "what share of internet users are college graduates".
- χ² on its own: grows with sample size. To compare tables of different sizes, use C or T.
- Maximum value: C never reaches 1, and T only reaches 1 in 2 × 2 tables. Read each one against the maximum possible for the size of the table, shown in the measures panel.
- Association is not causation: the table shows that the variables go together, not why. A third variable, such as income, may be behind both.
- Formal test: deciding whether the association goes beyond chance is the job of the chi-squared test of independence (Morettin and Bussab, ch. 14; Agresti and Finlay, ch. 8). In R, chisq.test() applies Yates' correction to 2 × 2 tables; use correct = FALSE to get the descriptive χ² shown here.
With two categorical variables, the starting point is the contingency table: each cell counts the observations that fall at the same time in one row category and one column category. How you read it depends on the base of the percentages, and the base comes from the question. When one variable helps explain the other, as education explains internet use, the explanatory variable goes in the rows and the percentages are computed within each row. Agresti and Finlay describe the table this way, with the response as percentages within each category of the explanatory variable.
If the variables were independent, every row would have the same profile as the Total row. Morettin and Bussab measure how far the table is from that by comparing each observed frequency \(n_{ij}\) with the frequency expected under independence, \(n^*_{ij} = n_{i\cdot}\, n_{\cdot j} / n\). The result is Pearson's chi-squared, \(\chi^2 = \sum_i \sum_j (n_{ij} - n^*_{ij})^2 / n^*_{ij}\), which is 0 when observed and expected match and grows as they move apart. Since \(\chi^2\) also grows with \(n\), the book offers two coefficients that do not depend on sample size: the contingency coefficient, \(C = \sqrt{\chi^2 / (\chi^2 + n)}\), and \(T = \sqrt{(\chi^2 / n) / ((r - 1)(s - 1))}\), where \(r\) and \(s\) are the numbers of rows and columns.
Try it: set the strength of the association to 0 and draw a few samples. The variables are independent in the population, but the sample \(\chi^2\) is almost never exactly 0, since chance always pulls the rows a little apart. Then raise the strength and watch the profiles separate in the chart.