Goodness‑of‑fit & Test of Independence — interactive contingency tables, expected frequencies, and exact p‑values. Built for researchers, students, and data analysts.
The Pearson’s chi‑square test (χ²) is a fundamental statistical method used to assess whether observed categorical data deviates significantly from expected outcomes. Developed by Karl Pearson in 1900, it evaluates two main scenarios: goodness‑of‑fit (testing if a sample follows a hypothesized distribution) and test of independence (examining association between two categorical variables).
Under the null hypothesis, the test statistic approximately follows a chi‑square distribution with degrees of freedom (df) = (r‑1)(c‑1) for contingency tables, or (k‑1) for goodness‑of‑fit.
A clinical trial compares recovery rates among three treatment groups. The chi‑square test of independence can determine if recovery status (recovered / not recovered) is associated with treatment type. For example, load the example in the independence tab — a 2×3 table representing treatment outcomes. Our calculator automatically computes χ² = 6.43, df = 2, p = 0.04, indicating significant association at α = 0.05.
To quantify the strength of association beyond the p‑value, use Cramér’s V (for R×C tables): \( V = \sqrt{\chi^2 / (N \cdot \min(r-1, c-1))} \). For 2×2 tables, the Phi coefficient (φ) is equivalent to V. As a rough guideline: V ≈ 0.1 indicates small, 0.3 medium, and 0.5 large effect. You can compute V manually from the χ² and N provided by our results.
When expected frequencies are too low (more than 20% of cells with E<5), the chi‑square approximation may be unreliable. For 2×2 tables, consider Fisher’s exact test (available in many statistical packages). For larger tables, consider Monte Carlo simulation or combining sparse categories. Our calculator displays a warning when expected frequencies fall below 5, but it does not automatically switch to exact methods.