01 / 20

Chi-Square Test
of Independence

Discover how to determine whether two categorical variables are related using the powerful \( \chi^2 \) test of independence.

College Statistics

What Is the \( \chi^2 \) Test of Independence?

The chi-square test of independence is a hypothesis test used to determine whether there is a statistically significant association between two categorical variables. It answers: are these two variables independent, or are they related?

Working with Categorical Variables

Categorical Variable
A variable that takes on labels or categories rather than numbers: e.g., gender, party affiliation, favorite color.
Contingency Table
A two-way table that displays the frequency counts for every combination of categories of the two variables.

Anatomy of a Contingency Table

Healthy Unhealthy Row Total
None 15 35 50
Moderate 40 30 70
High 55 25 80
Column Total 110 90 200

Setting Up the Hypotheses

\( H_0 \): Null Hypothesis
The two categorical variables are independent: there is no association between them.
\( H_a \): Alternative Hypothesis
The two categorical variables are not independent: there is an association between them.

The \( \chi^2 \) Statistic Formula

O
Observed frequency: The actual count in each cell of the contingency table.
E
Expected frequency: The count we would expect if \( H_0 \) were true (variables are independent).
Σ
Summation: We compute \( \frac{(O-E)^2}{E} \) for every cell and sum them all up.

Computing Expected Frequencies

For each cell in the contingency table, the expected frequency assumes the row and column variables are independent. If they are, the proportion in each cell should reflect the product of the marginal proportions.

Degrees of Freedom

\( r \)
Number of rows in the contingency table (excluding totals).
\( c \)
Number of columns in the contingency table (excluding totals).
Example
Our 3 x 2 table: \( df = (3-1)(2-1) = \) 2.

The \( \chi^2 \) Distribution

0 2 4 6 8 10 Chi-Square Value df = 1 df = 2 df = 5

Independence vs Goodness of Fit

Test of Independence Goodness of Fit
Purpose Are two variables related? Does one variable match a specified distribution?
Variables Two categorical variables One categorical variable
Data Format Two-way contingency table One-way frequency table
df Formula \( (r-1)(c-1) \) \( k - 1 \)
Expected Values From marginals From hypothesized proportions

Conditions for Validity

1
Random sampling: The data must come from a random sample or randomized experiment.
2
Independence of observations: Each observation is counted in exactly one cell. The sample size must be < 10% of the population.
3
Large expected counts: All expected cell frequencies must be at least 5. If any cell has \( E < 5 \), consider combining categories or using Fisher's exact test.

How to Perform the \( \chi^2 \) Test

1
State hypotheses: \( H_0 \): variables are independent. \( H_a \): variables are not independent.
2
Check conditions: Random sample, independence of observations, all \( E \geq 5 \).
3
Compute expected values: For each cell, \( E = \frac{\text{Row Total} \times \text{Column Total}}{\text{Grand Total}} \).
4
Compute the test statistic: \( \chi^2 = \sum \frac{(O-E)^2}{E} \).
5
Find the p-value: Use \( df = (r-1)(c-1) \) and a \( \chi^2 \) table or calculator.
6
Conclude: If \( p \leq \alpha \), reject \( H_0 \). There is evidence of an association.

Worked Example: Setup

A researcher surveys 200 students on study method (Flashcards, Practice Problems, Reading) and exam result (Pass, Fail). Is there an association at \( \alpha = 0.05 \)?

Pass Fail Total
Flashcards 38 12 50
Practice Problems 56 14 70
Reading 42 38 80
Total 136 64 200

Expected Values Computed

Pass (E) Fail (E)
Flashcards \( \frac{50 \times 136}{200} = 34 \) \( \frac{50 \times 64}{200} = 16 \)
Practice Problems \( \frac{70 \times 136}{200} = 47.6 \) \( \frac{70 \times 64}{200} = 22.4 \)
Reading \( \frac{80 \times 136}{200} = 54.4 \) \( \frac{80 \times 64}{200} = 25.6 \)

Computing \( \chi^2 \)

1
Flashcards/Pass: \( \frac{16}{34} = 0.471 \)
2
Flashcards/Fail: \( \frac{16}{16} = 1.000 \)
3
Practice/Pass: \( \frac{70.56}{47.6} = 1.482 \)
4
Practice/Fail: \( \frac{70.56}{22.4} = 3.150 \)
5
Reading/Pass: \( \frac{153.76}{54.4} = 2.826 \)
6
Reading/Fail: \( \frac{153.76}{25.6} = 6.006 \)

Drawing a Conclusion

5.991 Critical Value 14.935 Our Statistic Fail to reject Reject

Common Mistakes

✕ Using Observed for Expected
Checking \( O \geq 5 \) instead of \( E \geq 5 \). The condition applies to expected counts only.
✕ Wrong df Formula
Using \( n - 1 \) or counting total cells. Remember: \( df = (r-1)(c-1) \), not \( rc - 1 \).
✕ Claiming Causation
Rejecting \( H_0 \) shows association, not causation. Only experiments can establish cause and effect.

Summary at a Glance

Component Details
Purpose Test whether two categorical variables are independent
Formula \( \chi^2 = \sum \frac{(O-E)^2}{E} \)
Expected Value \( E = \frac{\text{Row Total} \times \text{Col Total}}{\text{Grand Total}} \)
Degrees of Freedom \( (r - 1)(c - 1) \)
Key Condition All expected counts \( \geq 5 \)
Decision Rule Reject \( H_0 \) if \( \chi^2 \geq \chi^2_{\text{crit}} \) or if \( p \leq \alpha \)
Conclusion Evidence of association (not causation)

Interpreting the P-Value

The p-value represents the probability of observing a \( \chi^2 \) value as extreme or more extreme than our test statistic, assuming \( H_0 \) is true. A smaller p-value provides stronger evidence against independence.

\( p \leq \alpha \)
Reject \( H_0 \): Sufficient evidence of an association between the variables.
\( p > \alpha \)
Fail to reject \( H_0 \): Insufficient evidence of an association. The variables may be independent.

Question 1 of 5

The null hypothesis for a chi-square test of independence states that:

Question 2 of 5

A contingency table has 4 rows and 3 columns. What are the degrees of freedom for the \( \chi^2 \) test of independence?

Question 3 of 5

In a \( 2 \times 2 \) table, one cell has a row total of 30, a column total of 40, and a grand total of 200. What is the expected frequency for that cell?

Question 4 of 5

Which condition must be met before performing a chi-square test of independence?

Question 5 of 5

A chi-square test of independence yields \( \chi^2 = 9.21 \) with \( df = 2 \). The critical value at \( \alpha = 0.01 \) is 9.210. What is the correct conclusion?