Analyse categorical data with contingency tables
8 steps · about 1 h 58 min · Intermediate
- Build a reproducible cross-tabulation (article, statsmodels documentation, 15 min)
Turn two categorical variables into counts, margins and useful proportions.
- State the independence question (article, NIST/SEMATECH e-Handbook, 15 min)
Translate the research question into observed and expected cell counts.
- Inspect expected frequencies (reference, statsmodels documentation, 10 min)
Check the model-implied table before relying on an asymptotic test.
- Run and unpack a chi-square test (reference, SciPy documentation, 18 min)
Calculate the statistic, degrees of freedom, p-value and expected counts in code.
- Use an exact test for sparse 2×2 data (reference, SciPy documentation, 15 min)
Choose a method suited to small counts rather than forcing a large-sample approximation.
- Check test conditions explicitly (article, NIST/SEMATECH e-Handbook, 15 min)
Decide whether independence and expected-count requirements are credible for the data.
- Measure association with Cramér's V (article, NIST Dataplot, 12 min)
Add an interpretable effect-size summary instead of stopping at significance.
- Report patterns and limits (article, NIST/SEMATECH e-Handbook, 18 min)
Read cell contributions, describe the association and keep causal claims outside the evidence.