Chi-Square Test: Goodness of Fit and Test of Independence
Overviewβ
The Chi-Square (ΟΒ²) test is the workhorse of categorical data analysis in psychology. Where correlation and t-tests operate on continuous variables, the chi-square test works with frequencies in categories β answering two related questions:
- Goodness of Fit: Do observed category frequencies match theoretically expected frequencies?
- Test of Independence: Are two categorical variables related to each other?
Unlike the other non-parametric tests in this block, chi-square does not involve ranking at all β it works directly with counts in cells of a frequency table.
Where = Observed frequency and = Expected frequency.
4.7 The Chi-Square Test: Two Functionsβ
Function 1: Goodness of Fitβ
Tests whether an observed distribution of frequencies across categories matches an expected distribution.
Hβ: The observed frequencies do not differ significantly from the expected frequencies. Hβ: At least one observed frequency differs significantly from its expected value.
When is it used?
- Checking whether survey responses follow a predicted distribution
- Testing whether a die is fair (equal frequencies expected)
- Comparing this year's customer preferences to last year's
Function 2: Test of Independence (Contingency Table Analysis)β
Tests whether two categorical variables are related or independent of each other.
Hβ: The two variables are independent (no association). Hβ: The two variables are associated (not independent).
When is it used?
- Testing whether gender is related to voting preference
- Examining whether caste category is associated with educational attainment
- Assessing whether treatment type is related to recovery outcome category
4.8 Assumptions and Backgroundβ
The chi-square goodness-of-fit test rests on three assumptions (Siegel & Castellan, 1988):
-
Categorical nominal data: Test data must represent frequencies for mutually exclusive categories. Each observation belongs to one and only one cell.
-
Independent random observations: Each subject/observation appears in the data only once. Repeated-measures designs violate this assumption.
-
Expected frequency β₯ 5 per cell: The chi-square approximation becomes unreliable when expected frequencies are very small.
Following Cochran (1952/1954):
- No expected cell frequency should be < 1
- No more than 20% of cells should have expected frequency < 5
When this rule is violated: for 2Γ2 tables, use Fisher's Exact Test. For larger tables, consider collapsing categories. Note that different sources debate how strict this rule needs to be β it is somewhat conservative.
What Counts as Valid Cell Dataβ
The chi-square formula requires actual frequency counts in cells:
| β Valid | β Invalid |
|---|---|
| Number of people choosing each colour | Percentages |
| Count of students in each grade category | Means of a scale |
| Frequency of each response category | Proportions |
One person, one cell β no double-counting.
4.9 Step-by-Step: Chi-Square Goodness of Fitβ
The Six Stepsβ
- Record Observed frequencies (O) in each category
- Determine Expected frequencies (E) β either from equal distribution assumption or from prior proportions
- Compute across all categories
- Calculate degrees of freedom: (where = number of categories)
- Look up critical in the chi-square table at chosen and
- Decision: Reject Hβ if calculated critical
Worked Example 1: Car Colour Preferences (Goodness of Fit)β
Research Questionβ
A car dealership manager surveyed 150 customers about colour preferences. Based on last year's sales, expected proportions were: Yellow 20%, Red 30%, Green 10%, Blue 10%, White 30%. Do this year's preferences significantly differ from last year?
Data Tableβ
| Colour | Observed (O) | Expected % | Expected (E) | O β E | (OβE)Β² | (OβE)Β²/E |
|---|---|---|---|---|---|---|
| Yellow | 35 | 20% | 30 | +5 | 25 | 0.83 |
| Red | 50 | 30% | 45 | +5 | 25 | 0.56 |
| Green | 30 | 10% | 15 | +15 | 225 | 15.00 |
| Blue | 10 | 10% | 15 | β5 | 25 | 1.67 |
| White | 25 | 30% | 45 | β20 | 400 | 8.89 |
| Total | 150 | 150 | ΟΒ² = 26.95 |
Expected frequencies are calculated as: (e.g., Yellow: 0.20 Γ 150 = 30)
df = k β 1 = 5 β 1 = 4
Critical ΟΒ² at Ξ± = .05, df = 4: 9.49
Since 26.95 > 9.49 β Reject Hβ
Conclusion: Customer colour preferences have changed significantly since last year. The largest discrepancies are in Green (observed twice as many as expected) and White (observed about half as many as expected). The manager should adjust inventory accordingly.
Step-by-Step: Chi-Square Test of Independenceβ
For the independence test, expected frequencies are calculated from the marginal totals:
Degrees of freedom = where = rows, = columns
Worked Example 2: Traffic Stop Behaviour by Genderβ
Research Questionβ
Does stopping behaviour at traffic signs differ between male and female drivers?
Observed Frequenciesβ
| Male | Female | Row Total | |
|---|---|---|---|
| Full Stop | 6 | 6 | 12 |
| Rolling Stop | 16 | 15 | 31 |
| No Stop | 4 | 3 | 7 |
| Column Total | 26 | 24 | 50 |
Step 1β2: Compute Expected Frequenciesβ
| Cell | Calculation | Expected |
|---|---|---|
| Male / Full Stop | (12 Γ 26) / 50 | 6.24 |
| Female / Full Stop | (12 Γ 24) / 50 | 5.76 |
| Male / Rolling Stop | (31 Γ 26) / 50 | 16.12 |
| Female / Rolling Stop | (31 Γ 24) / 50 | 14.88 |
| Male / No Stop | (7 Γ 26) / 50 | 3.64 |
| Female / No Stop | (7 Γ 24) / 50 | 3.36 |
Step 3: Compute ΟΒ²β
| Cell | O | E | (OβE)Β² / E |
|---|---|---|---|
| Male/Full Stop | 6 | 6.24 | 0.009 |
| Female/Full Stop | 6 | 5.76 | 0.010 |
| Male/Rolling Stop | 16 | 16.12 | 0.001 |
| Female/Rolling Stop | 15 | 14.88 | 0.001 |
| Male/No Stop | 4 | 3.64 | 0.036 |
| Female/No Stop | 3 | 3.36 | 0.039 |
| ΟΒ² | β 0.095 |
df = (3 β 1)(2 β 1) = 2
Critical ΟΒ² at Ξ± = .05, df = 2: 5.99
Since 0.095 < 5.99 β Fail to reject Hβ
Conclusion: Stopping behaviour does not differ significantly between male and female drivers.
4.10 Further Considerationsβ
Low Expected Frequenciesβ
When any expected cell frequency falls below 5, the chi-square approximation becomes unreliable:
| Situation | Recommended Solution |
|---|---|
| 2Γ2 table with any E < 5 | Use Fisher's Exact Test |
| Larger table with some E < 5 | Collapse adjacent categories to raise expected frequencies |
| Very small total N (< 20) | Reconsider design; increase sample size |
Mutual Exclusivity Requirementβ
Each observation must appear in one and only one cell. If a person could belong to multiple categories simultaneously (e.g., a swimmer who is also a hurdler), chi-square is invalid. This is a design issue, not a calculation fix.
Goodness of Fit vs. Independence: Reading the Tableβ
| Function | Critical Region |
|---|---|
| Goodness of Fit | Right tail: reject if ΟΒ² β₯ ΟΒ²-crit (standard Ξ± = .05) |
| Independence | Right tail: reject if ΟΒ² β₯ ΟΒ²-crit (same logic) |
Both use the right tail β a large ΟΒ² in either direction means observed and expected frequencies diverge substantially.
Chi-Square in SPSSβ
Goodness of Fitβ
Analyse β Non-Parametric Tests β Legacy Dialogs β Chi-Square
- Move test variable to Test Variable List
- Under Expected Values: choose "All categories equal" OR enter custom expected proportions under "Values"
- Click OK
Test of Independence (Crosstabs)β
Analyse β Descriptive Statistics β Crosstabs
- Place one variable in Rows, the other in Columns
- Click Statistics β check Chi-Square β Continue
- Click Cells β check Expected (to display expected frequencies) β Continue
- Click OK
Reading SPSS Outputβ
- Chi-Square Tests table: Look for "Pearson Chi-Square" row β read the ΟΒ² value, df, and Asymptotic Significance (p-value)
- Cells with expected frequency < 5: SPSS will flag how many cells violate this assumption
- Fisher's Exact Test: Automatically provided for 2Γ2 tables
Self-Assessment Questionsβ
Level 1 β Recallβ
-
Write the chi-square formula and label each component.
-
What are the two functions of the chi-square test? Give one research example for each.
-
How is the expected frequency calculated in (a) the goodness of fit test when equal distribution is assumed, and (b) the test of independence?
Level 2 β Applicationβ
-
A researcher surveys 200 students about their preferred study method: 80 prefer visual, 60 prefer auditory, and 60 prefer kinaesthetic. If the null hypothesis states equal preference across the three modes, what are the expected frequencies? Compute ΟΒ² and determine significance at Ξ± = .05 with df = 2 (critical ΟΒ² = 5.99).
-
In a 2Γ3 contingency table (2 genders Γ 3 therapy preferences), what are the degrees of freedom? If one cell has an expected frequency of 3.2, does this violate the Cochran rule? What would you do?
Level 3 β Critical Thinkingβ
-
A student computes ΟΒ² = 4.0 for a 2Γ2 table with very small cell counts (total N = 16, two cells have expected frequencies of 4). The calculated value exceeds the critical value of 3.84. Should the student reject Hβ? Explain the risks and appropriate alternative procedure.
-
A researcher asks: "Can I use chi-square to test whether average therapy satisfaction scores differ between two groups?" What is wrong with this proposal? What test would be appropriate, and why?
π§ Memory Aidβ
"Chi-square = ODES" (for the calculation workflow):
- Observed frequencies β record what you actually measured
- Determine expected frequencies β equal distribution or from prior data
- Evaluate: compute for each cell and sum
- Significance: compare to critical ΟΒ² at df = kβ1 (goodness of fit) or (rβ1)(cβ1) (independence)
Three "C" assumptions of Chi-Square:
- Categorical data (frequencies, not means or percentages)
- Cells are mutually exclusive (one person, one cell)
- Cell expected frequencies β₯ 5 (Cochran's rule)
Real-World Indian Applicationsβ
Chi-square is among the most widely used tests in Indian social science research:
| Research Context | Variables | Chi-Square Type |
|---|---|---|
| NFHS health surveys | Region Γ Vaccination status | Test of Independence |
| Educational research | School type (govt/private) Γ Pass/fail rate | Test of Independence |
| Consumer psychology | Age category Γ Brand preference | Test of Independence |
| Clinical trials | Treatment group Γ Recovery category | Test of Independence |
| Behavioural studies | Predicted behaviour distribution vs. observed | Goodness of Fit |
π External Resourcesβ
Foundational Readingβ
- π Wikipedia: Chi-squared test β Full mathematical background, history, and variants
- π Wikipedia: Fisher's exact test β Small sample alternative to chi-square
Tutorialsβ
- π Laerd Statistics: Chi-Square Goodness of Fit β SPSS guide with assumptions check
- π Statistics How To: Chi-Square Test β Multiple worked examples
- π Real Statistics: Chi-Square Tests in Excel β Excel implementation
Videosβ
- π₯ Chi-Square Test β CrashCourse Statistics β Accessible conceptual overview
- π₯ SPSS Chi-Square Test Tutorial β Full SPSS walkthrough
Research Articlesβ
- π Cochran, W. G. (1952). The chi-square test of goodness of fit. Annals of Mathematical Statistics, 23(3), 315β345. (Source of the "expected frequency β₯ 5" rule)
- π Franke, T. M., Ho, T., & Christie, C. A. (2012). The chi-square test: Often used and more often misinterpreted. American Journal of Evaluation, 33(3), 448β458.
- π McHugh, M. L. (2013). The chi-square test of independence. Biochemia Medica, 23(2), 143β149.
Source PDFs:
- π Block-4/Unit-4.pdf β Pages 58β66
- π MPC-006 Statistics in Psychology