Why Test Independence?
A contingency table summarizes counts for two categorical variables. For example, a hypothetical study might classify each participant by the type of reminder received and whether the participant completed a follow-up form. The central question is whether the distribution of completion status differs across reminder types, or whether the two classifications are independent.
The Pearson chi-square test of independence compares the observed cell counts with the counts expected if the variables were independent. The method is aligned with the SOA VEE Mathematical Statistics syllabus. It is a test about categorical classifications and their joint counts, not a test about means or numerical measurements.
Hypotheses and Expected Counts
The null hypothesis is that the two categorical variables are independent in the population. The alternative is that they are associated: at least one joint-category probability differs from what independence implies. The test does not identify a causal relationship.
Under independence, the probability of falling in row \(i\) and column \(j\) is the row probability multiplied by the column probability. Estimating those marginal probabilities with the observed row and column proportions gives the expected count for each cell.
Here \(E_{ij}\) is the expected count under the null hypothesis. It need not be an integer. The observed counts are the actual frequencies; the expected counts are the frequencies predicted by independence while retaining the table’s observed margins.
For the usual large-sample test, compare \(X^2\) with a chi-square distribution having \((r-1)(c-1)\) degrees of freedom under the null hypothesis. Equivalently, find the upper-tail p-value \(P(\chi^2_{(r-1)(c-1)}\ge X^2)\). Small p-values indicate that the observed departures would be unusual if the variables were independent. The expected-count and degrees-of-freedom formulas are used here to carry out the test; they should not be confused with the statistic itself.
Why the Expected-Count Formula Holds
Under independence, let \(p_{i+}\) be the probability of row \(i\), and \(p_{+j}\) the probability of column \(j\). The probability of cell \((i,j)\) is \(p_{i+}p_{+j}\). In \(n\) observations, its expected count is therefore \(np_{i+}p_{+j}\). Replacing the unknown marginal probabilities with their observed proportions gives \(p_{i+}\approx R_i/n\) and \(p_{+j}\approx C_j/n\), so
This also explains why the expected counts add to the observed margins. For row \(i\), summing across columns gives \(\sum_j E_{ij}=R_i\), because \(\sum_j C_j=n\). Thus the test asks whether the pattern inside the table departs from independence, not whether the row or column totals match some separately specified distribution.
Conditions for Using the Test
Before interpreting the chi-square reference distribution, check that the data and approximation are suitable. The usual setup has one count per observational unit, with each unit classified into exactly one category of each variable. Observations should be independent of one another, and the categories should be mutually exclusive and exhaustive for the classifications being analyzed.
The chi-square approximation can be unreliable when expected counts are too small. A commonly used guideline is that expected counts should generally be at least 5; other conventions allow a small fraction below 5 provided none is below 1. Follow the stated convention for the problem. These are approximation guidelines, not a change to the formula for \(X^2\). If the conditions are poor, a suitable exact procedure or a different analysis may be needed.
Worked Example: Reminder Type and Form Completion
In a hypothetical study, 100 participants are classified by reminder type and whether they complete a follow-up form. The counts are:
| Reminder type | Completed | Not completed | Total |
|---|---|---|---|
| Text | 30 | 20 | 50 |
| 10 | 40 | 50 | |
| Total | 40 | 60 | 100 |
Test independence at the 5% significance level. Assume the participants are independent observational units and the expected-count guideline is satisfied.
Method and hypotheses. Use Pearson’s chi-square test of independence. The null hypothesis is that reminder type and completion status are independent; the alternative is that they are associated.
Expected counts. For text and completed, \(E_{11}=(50)(40)/100=20\). For text and not completed, \(E_{12}=(50)(60)/100=30\). The email row has the same total, so \(E_{21}=(50)(40)/100=20\) and \(E_{22}=(50)(60)/100=30\).
Statistic. The four contributions are \( (30-20)^2/20=100/20=5\), \( (20-30)^2/30=100/30=3.3333\), \( (10-20)^2/20=100/20=5\), and \( (40-30)^2/30=100/30=3.3333\). Thus \(X^2=5+3.3333+5+3.3333=16.6667\), to four decimal places.
Reference distribution and conclusion. The degrees of freedom are \((2-1)(2-1)=1\). At the 5% level the critical value is approximately 3.841. Since \(16.6667>3.841\), reject independence at that level. There is evidence of an association between reminder type and completion status in this hypothetical study.
Check and trap avoided. The expected counts add to row totals 50 and 50, and to column totals 40 and 60. A common error is to compare each observed count with \(n/(rc)=100/4=25\). That would incorrectly assign 25 to every cell; expected counts must instead use each cell’s own row and column margins.
Interpreting the Statistic and the Decision
The test statistic measures total discrepancy, scaled by the expected count in each cell. Squaring prevents positive and negative deviations from canceling; dividing by \(E_{ij}\) scales the discrepancy relative to the size of the expected count. Because larger values are less compatible with the null hypothesis, the rejection region is in the upper tail.
A decision is always made relative to a specified significance level. If the p-value is at most \(\alpha\), reject independence; otherwise, do not reject independence. “Do not reject” means the data do not provide sufficient evidence against independence at that level. It does not establish that the variables are independent. The test also does not measure the practical importance of an association.
Worked Example: Three Service Categories and Two Outcomes
A hypothetical service team records whether a request was resolved on its first review for three request categories. The counts are:
| Request category | Resolved first review | Not resolved first review | Total |
|---|---|---|---|
| Account | 18 | 12 | 30 |
| Payment | 12 | 18 | 30 |
| Access | 10 | 10 | 20 |
| Total | 40 | 40 | 80 |
Test for independence at the 5% significance level. Assume independent observations and use the Pearson chi-square approximation.
Method and hypotheses. Apply the independence test with request category as the row variable and resolution status as the column variable. The null is independence; the alternative is association.
Expected counts. For each of the first two rows, the expected count in either outcome column is \((30)(40)/80=15\). For the access row, the expected count in either column is \((20)(40)/80=10\). Thus the expected rows are \((15,15)\), \((15,15)\), and \((10,10)\). All expected counts meet the stated guideline.
Statistic. The account row contributes \((18-15)^2/15+(12-15)^2/15=9/15+9/15=1.2\). The payment row contributes \((12-15)^2/15+(18-15)^2/15=1.2\). The access row contributes \(0\), since both observed counts equal their expected counts. Therefore \(X^2=1.2+1.2+0=2.4\).
Reference distribution and conclusion. The degrees of freedom are \((3-1)(2-1)=2\). The 5% critical value is approximately 5.991. Since \(2.4<5.991\), do not reject independence at the 5% level. These data do not provide sufficient evidence of an association between request category and first-review resolution.
Check and trap avoided. The expected counts sum to 30, 30, and 20 by row, and to 40 in each outcome column. A common mistake is to report that the variables “are independent” because the test did not reject. The conclusion must describe the evidence, not claim that independence has been proved.
Worked Example: A Significant Two-by-Three Table
A hypothetical survey classifies 80 respondents by plan type and preferred service channel:
| Plan type | Online | Phone | In person | Total |
|---|---|---|---|---|
| Basic | 20 | 10 | 10 | 40 |
| Plus | 10 | 15 | 15 | 40 |
| Total | 30 | 25 | 25 | 80 |
Test independence at the 1% significance level. Assume respondents are independent and the expected-count conditions are met.
Method and hypotheses. Use the Pearson test. The null hypothesis is independence of plan type and channel preference; the alternative is an association between them.
Expected counts. For each plan type, the expected counts are \((40)(30)/80=15\) online, \((40)(25)/80=12.5\) by phone, and \((40)(25)/80=12.5\) in person. Both expected rows are therefore \((15,12.5,12.5)\).
Statistic. The basic-plan contributions are \((20-15)^2/15=25/15=1.6667\), \((10-12.5)^2/12.5=6.25/12.5=0.5\), and \(0.5\). The plus-plan contributions are \(25/15=1.6667\), \(6.25/12.5=0.5\), and \(0.5\). Adding gives \(X^2=1.6667+0.5+0.5+1.6667+0.5+0.5=5.3334\), or \(5.3333\) using unrounded terms, to four decimal places.
Reference distribution and conclusion. The degrees of freedom are \((2-1)(3-1)=2\). The 1% critical value is approximately 9.210. Since \(5.3333<9.210\), do not reject independence at the 1% level. The result is not significant at this stricter threshold, even though the observed counts differ from their expected counts.
Check and trap avoided. Each expected row sums to 40, and the expected column totals are 30, 25, and 25. A common mistake is to round 12.5 to an integer before calculating the statistic. Keeping the expected counts unrounded avoids unnecessary calculation error; rounding the final statistic only does not change the decision here.
Common Exam Traps
- Using equal expected counts automatically. Expected counts are equal only when the margins imply equal counts. Use \(R_iC_j/n\) cell by cell.
- Using the wrong reference distribution. The test uses an upper-tail chi-square reference distribution, with degrees of freedom determined by the table dimensions.
- Confusing the two kinds of independence. Independent observations are an assumption about how units relate to one another; independence of the categorical variables is the null hypothesis being tested.
- Making a stronger conclusion than the test supports. A small p-value is evidence against independence, not proof of a causal effect. A large p-value does not prove independence.
- Ignoring small expected counts. Check expected counts, not observed counts, when assessing whether the chi-square approximation is suitable.
Check Your Understanding
For each problem, calculate the expected counts and Pearson statistic, then state the test conclusion at the specified significance level. Use the usual chi-square approximation where expected counts are adequate.
- A hypothetical 2-by-2 table has rows \((24,16)\) and \((16,24)\), with row totals 40 and column totals 40. Test independence at 5%. (Answer: Each expected count is 20; \(X^2=3.2\), df \(=1\); do not reject independence at 5%.)
- A hypothetical 3-by-2 table has rows \((14,6)\), \((10,10)\), and \((6,14)\). Test independence at 5%. (Answer: Every expected count is 10; \(X^2=6.4\), df \(=2\); reject independence at 5%.)
- A hypothetical 2-by-3 table has rows \((12,18,10)\) and \((18,12,10)\). Test independence at 5%. (Answer: Expected rows are \((15,15,10)\) and \((15,15,10)\); \(X^2=2.4\), df \(=2\); do not reject independence at 5%.)
- A hypothetical 2-by-2 table has rows \((45,15)\) and \((15,25)\). Test independence at 5%. (Answer: Expected rows are \((36,24)\) and \((24,16)\); \(X^2=14.0625\), df \(=1\); reject independence at 5%.)
- A hypothetical 3-by-2 table has rows \((25,15)\), \((20,20)\), and \((15,25)\). Test independence at 5%. (Answer: Every expected count is 20; \(X^2=5\), df \(=2\); do not reject independence at 5%.)