Degrees of Freedom for Independence Tests
What you'll learn: How to calculate the degrees of freedom when testing independence between two categorical variables in a contingency table.
The Core Concept
When you perform a chi-squared test of independence on a contingency table, you need to know the degrees of freedom to find the critical value or p-value. The formula is straightforward:
Degrees of Freedom = (number of rows - 1) × (number of columns - 1)
or simply: df = (r - 1) × (c - 1)
Why This Formula?
Think of degrees of freedom as the number of "free choices" you have when filling in a table. Imagine you have a 3×2 contingency table where all row and column totals are fixed. If you fill in values for 2 rows and 1 column (that's (3-1)×(2-1) = 2 cells), the rest of the table is completely determined by the marginal totals—you have no freedom left to choose those values.
The "-1" accounts for the constraint that each row must sum to its total, and each column must sum to its total.
Examples
- 2×2 table (e.g., gender × product preference): df = (2-1) × (2-1) = 1
- 3×4 table (e.g., age group × favorite season): df = (3-1) × (4-1) = 6
- 5×3 table (e.g., education level × political party): df = (5-1) × (3-1) = 8
Notice that larger tables have more degrees of freedom, reflecting greater complexity in the relationship you're testing.
Key Takeaway: For chi-squared independence tests, always calculate degrees of freedom as (rows - 1) × (columns - 1) to determine the correct critical value for your hypothesis test.