Skip to main content

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:

  1. Goodness of Fit: Do observed category frequencies match theoretically expected frequencies?
  2. 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.

Ο‡2=βˆ‘(Oβˆ’E)2E\chi^2 = \sum \frac{(O - E)^2}{E}

Where OO = Observed frequency and EE = 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):

  1. Categorical nominal data: Test data must represent frequencies for kk mutually exclusive categories. Each observation belongs to one and only one cell.

  2. Independent random observations: Each subject/observation appears in the data only once. Repeated-measures designs violate this assumption.

  3. Expected frequency β‰₯ 5 per cell: The chi-square approximation becomes unreliable when expected frequencies are very small.

The Expected Frequency Rule

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 colourPercentages
Count of students in each grade categoryMeans of a scale
Frequency of each response categoryProportions

One person, one cell β€” no double-counting.


4.9 Step-by-Step: Chi-Square Goodness of Fit​

The Six Steps​

  1. Record Observed frequencies (O) in each category
  2. Determine Expected frequencies (E) β€” either from equal distribution assumption or from prior proportions
  3. Compute Ο‡2=βˆ‘(Oβˆ’E)2E\chi^2 = \sum \frac{(O-E)^2}{E} across all categories
  4. Calculate degrees of freedom: df=kβˆ’1df = k - 1 (where kk = number of categories)
  5. Look up critical Ο‡2\chi^2 in the chi-square table at chosen Ξ±\alpha and dfdf
  6. Decision: Reject Hβ‚€ if calculated Ο‡2β‰₯\chi^2 \geq critical Ο‡2\chi^2

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​

ColourObserved (O)Expected %Expected (E)O βˆ’ E(Oβˆ’E)Β²(Oβˆ’E)Β²/E
Yellow3520%30+5250.83
Red5030%45+5250.56
Green3010%15+1522515.00
Blue1010%15βˆ’5251.67
White2530%45βˆ’204008.89
Total150150χ² = 26.95

Expected frequencies are calculated as: E=proportionΓ—NE = \text{proportion} \times N (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:

Eij=RowiΒ totalΓ—ColumnjΒ totalNE_{ij} = \frac{\text{Row}_i \text{ total} \times \text{Column}_j \text{ total}}{N}

Degrees of freedom = (rβˆ’1)(cβˆ’1)(r - 1)(c - 1) where rr = rows, cc = 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​

MaleFemaleRow Total
Full Stop6612
Rolling Stop161531
No Stop437
Column Total262450

Step 1–2: Compute Expected Frequencies​

E=RowΒ TotalΓ—ColumnΒ TotalNE = \frac{\text{Row Total} \times \text{Column Total}}{N}

CellCalculationExpected
Male / Full Stop(12 Γ— 26) / 506.24
Female / Full Stop(12 Γ— 24) / 505.76
Male / Rolling Stop(31 Γ— 26) / 5016.12
Female / Rolling Stop(31 Γ— 24) / 5014.88
Male / No Stop(7 Γ— 26) / 503.64
Female / No Stop(7 Γ— 24) / 503.36

Step 3: Compute χ²​

CellOE(Oβˆ’E)Β² / E
Male/Full Stop66.240.009
Female/Full Stop65.760.010
Male/Rolling Stop1616.120.001
Female/Rolling Stop1514.880.001
Male/No Stop43.640.036
Female/No Stop33.360.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:

SituationRecommended Solution
2Γ—2 table with any E < 5Use Fisher's Exact Test
Larger table with some E < 5Collapse 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​

FunctionCritical Region
Goodness of FitRight tail: reject if χ² β‰₯ χ²-crit (standard Ξ± = .05)
IndependenceRight 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
  1. Move test variable to Test Variable List
  2. Under Expected Values: choose "All categories equal" OR enter custom expected proportions under "Values"
  3. Click OK

Test of Independence (Crosstabs)​

Analyse β†’ Descriptive Statistics β†’ Crosstabs
  1. Place one variable in Rows, the other in Columns
  2. Click Statistics β†’ check Chi-Square β†’ Continue
  3. Click Cells β†’ check Expected (to display expected frequencies) β†’ Continue
  4. 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​

  1. Write the chi-square formula and label each component.

  2. What are the two functions of the chi-square test? Give one research example for each.

  3. 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​

  1. 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).

  2. 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​

  1. 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.

  2. 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 (Oβˆ’E)2/E(O - E)^2 / E 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 ContextVariablesChi-Square Type
NFHS health surveysRegion Γ— Vaccination statusTest of Independence
Educational researchSchool type (govt/private) Γ— Pass/fail rateTest of Independence
Consumer psychologyAge category Γ— Brand preferenceTest of Independence
Clinical trialsTreatment group Γ— Recovery categoryTest of Independence
Behavioural studiesPredicted behaviour distribution vs. observedGoodness of Fit

πŸ“š External Resources​

Foundational Reading​

Tutorials​

Videos​

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: