Skip to content
Tutorials Center
My learning

Topics

Lesson 25 of 39 · Hypothesis Tests

Chi-Square Test of Independence in SPSS (Crosstabs)

Test the link between two categorical variables in SPSS with Crosstabs: expected counts, the chi-square assumption, Fisher's exact test, Cramér's V and reporting.

When both variables are categories (gender and preferred product, treatment group and recovered yes/no), you cannot compare means. Instead you count cases in each combination and ask whether the pattern of counts is what you would expect if the two variables were unrelated. That is the chi-square test of independence, and in SPSS it lives inside the Crosstabs procedure.

The idea

A contingency table (crosstab) shows counts for every pair of categories. If the variables were independent, each cell's expected count would be:

expected = (row total x column total) / grand total

The chi-square statistic adds up how far the observed counts are from those expected counts:

chi-square = sum of (observed - expected)^2 / expected

Large values mean the observed table differs a lot from independence. The degrees of freedom are (rows - 1) x (columns - 1).

Python Stand-in: expected counts and chi-square by hand

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Running it in SPSS

  1. Analyze > Descriptive Statistics > Crosstabs.
  2. Put one variable in Row(s) and the other in Column(s). Convention: the "cause" or group variable in rows, the outcome in columns.
  3. Statistics: tick Chi-square, and Phi and Cramer's V (an effect size for nominal data).
  4. Cells: tick Observed (default), Expected, and Row percentages (percentages of each group, which makes comparison easy). Under residuals you can also add Adjusted standardized.
  5. Optionally tick Display clustered bar charts.
  6. Paste:
Text
CROSSTABS
  /TABLES=group BY recovered
  /FORMAT=AVALUE TABLES
  /STATISTICS=CHISQ PHI
  /CELLS=COUNT EXPECTED ROW
  /COUNT ROUND CELL.

If your data are already summarised as counts (a column of frequencies), first tell SPSS the counts are weights: Data > Weight Cases > Weight cases by the count variable. Otherwise SPSS counts each summary row once.

Reading the output

  1. Case Processing Summary: valid N and missing cases.
  2. Crosstabulation: counts, expected counts and row percentages. Compare the row percentages first; they show the effect in plain language ("68% of the treatment group recovered versus 36% of the control group").
  3. Chi-Square Tests: several rows.
    • Pearson Chi-Square: the standard test. Use it for tables larger than 2x2 or when the 2x2 conditions hold.
    • Continuity Correction: for 2x2 only, a slightly conservative variant.
    • Likelihood Ratio: an alternative with the same large-sample answer.
    • Fisher's Exact Test: for 2x2 tables, exact p values for small counts.
    • Linear-by-Linear Association: for two ordered variables.
    • Footnote: "n cells (x%) have expected count less than 5."
  4. Symmetric Measures: Phi and Cramer's V with their significance.

The expected-count rule

The chi-square approximation needs enough data. The usual rule: no cell with an expected count below 1, and not more than 20% of cells with expected counts below 5. SPSS prints the footnote that tells you. If it is violated:

  • in a 2x2 table, read Fisher's Exact Test;
  • in a larger table, merge sparse categories sensibly (Transform > Recode) or collect more data.

Effect size: phi and Cramer's V

A significant chi-square only says "not independent". V measures strength from 0 to 1. For a 2x2 table phi equals V. Rough guides depend on table size; for df* = min(rows, columns) - 1 = 1, about .1 small, .3 medium, .5 large.

Python Stand-in: Cramér's V and Fisher's exact test

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Follow-up for bigger tables

In a 3x3 table a significant result does not say which cells drive it. Ask for adjusted standardized residuals in Cells: values beyond about +/-2 flag cells with more or fewer cases than expected.

Writing it up

"Recovery differed by treatment, chi-square(1, N = 100) = 10.3, p = .001, V = .32: 68% of the treatment group recovered versus 36% of controls." The figures come from the stand-in data above; use your own output.

Common mistakes

  • Running chi-square on percentages instead of counts.
  • Using it on repeated measures from the same people (use McNemar's test, also in Crosstabs under Statistics).
  • Ignoring the expected-count footnote.
  • Putting a continuous variable in as a category without grouping it meaningfully.
  • Interpreting the test as a causal claim.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which statistic does Crosstabs report to measure the strength of a nominal association?

    Phi and Cramer's V are effect sizes for chi-square tests on categorical variables.
  2. 2. SPSS footnote: '2 cells (50%) have expected count less than 5'. For a 2x2 table, what should you read?

    With small expected counts the exact test is more trustworthy than the chi-square approximation.
  3. 3. Your data are a table of counts, one row per combination of categories. What must you do before Crosstabs?

    Data > Weight Cases tells SPSS each row stands for that many cases.
  4. 4. How many degrees of freedom has a 3 x 4 table?

    (3 - 1) x (4 - 1) = 6.

Summary

  • Crosstabs (Analyze > Descriptive Statistics > Crosstabs) runs the chi-square test of independence for two categorical variables.
  • Ask for Chi-square and Phi and Cramer's V, with Expected counts and Row percentages.
  • Check the expected-count footnote; use Fisher's exact test for small 2x2 tables.
  • Report the statistic with df and N, p, V and the row percentages.

Next: Correlation Analysis