Statistics & probability
Contingency table chi-square test
Compare two categorical variables using an observed count table.
A clear answer. Here’s how.
First column supplies unique row labels; remaining column headers name categories. Counts must be whole and non-negative, with positive row/column totals. Computes expected counts from marginal totals, Pearson chi-square, df=(rows−1)(columns−1) and Cramér’s V. Uses an asymptotic p-value without Yates correction or an exact test; flags expected counts below 5. Assumes independent observations.
See a worked example
Worked example
A fixed demonstration, separate from the values you enter above.
- CSV count table: first column contains row labels
Group,Yes,No A,30,20 B,20,30
Example result
| Row | Column | Observed | Expected | Contribution |
|---|---|---|---|---|
| A | Yes | 30 | 25 | 1 |
| A | No | 20 | 25 | 1 |
| B | Yes | 20 | 25 | 1 |
| B | No | 30 | 25 | 1 |
df 1; asymptotic p-value 0.0455002638964; Cramér’s V 0.2. No expected count below 5. No Yates correction.