Analyse categorical data with contingency tables

8 steps · about 1 h 58 min · Intermediate

  1. Build a reproducible cross-tabulation (article, statsmodels documentation, 15 min)

    Turn two categorical variables into counts, margins and useful proportions.

  2. State the independence question (article, NIST/SEMATECH e-Handbook, 15 min)

    Translate the research question into observed and expected cell counts.

  3. Inspect expected frequencies (reference, statsmodels documentation, 10 min)

    Check the model-implied table before relying on an asymptotic test.

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

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

  6. Check test conditions explicitly (article, NIST/SEMATECH e-Handbook, 15 min)

    Decide whether independence and expected-count requirements are credible for the data.

  7. Measure association with Cramér's V (article, NIST Dataplot, 12 min)

    Add an interpretable effect-size summary instead of stopping at significance.

  8. Report patterns and limits (article, NIST/SEMATECH e-Handbook, 18 min)

    Read cell contributions, describe the association and keep causal claims outside the evidence.