2x2 Chi-Square Calculator
Enter the four counts of a 2x2 table. You get every common test for it on one screen, with advice on which one fits your expected counts.
Checked on November 21, 2026. Results computed by our statistics engine, version 1.0.0.
On this page
Why 2x2 tables get their own page
A 2x2 table is the most common contingency table and the one where software disagrees most. R and SciPy apply the Yates continuity correction by default (R chisq.test source, SciPy chi2_contingency); many textbooks and Campbell's 2007 study advise against it; Fisher's exact test avoids the approximation altogether. Rather than pick one silently, this page shows all of them, so you can match any textbook or program and see whether the choice matters for your data.
Worked example: an A/B test
Here is an illustrative A/B test of two landing pages with 1,000 visitors each. Version A converted 61 visitors and version B 38. These counts are pre-filled above.
| Converted | Did not convert | |
|---|---|---|
| Version A | 61 | 939 |
| Version B | 38 | 962 |
The conversion rates are 6.1% and 3.8%. The uncorrected Pearson χ² is 5.6217 with p = 0.0177. The Yates-corrected χ² is 5.1435 with p = 0.0233, and Fisher's exact test gives p = 0.0229. All three are below 0.05, so the conclusion is the same: evidence that the two versions convert at different rates.
The relative risk, 1.605, says version A converted about 61% more often, with a 95% confidence interval from 1.081 to 2.384. The odds ratio is 1.645 (1.086 to 2.490). With rare outcomes the two are close; with common outcomes the odds ratio is further from 1 than the relative risk.
Which of the tests to report
- Every expected count at least 5: the tests agree closely. Report the Pearson χ², or the Yates version if your field or software expects it, and say which.
- Some expected counts below 5 but all at least 1: Campbell (2007) found the N−1 chi-square, χ² × (N − 1) / N, kept error rates close to the nominal level (Campbell 2007).
- Any expected count below 1: use Fisher's exact test.
- More on these rules in expected counts and small samples, and the correction itself in the Yates guide.
Phi, odds ratio and relative risk
Phi is (ad − bc) / √(product of the four margins). Its size equals √(χ² / N), and its sign shows the direction: positive when the diagonal cells a and d are larger than expected. For the A/B example phi is 0.0530, a small effect.
The odds ratio is ad / bc, with a confidence interval from the log scale (Woolf's method). The relative risk compares the proportion in the first column between the two rows, with a log-scale (Katz) interval. Put the exposed or treatment group in row 1 and the outcome of interest in column 1, so the ratios read the natural way. When a cell is zero, the sample ratios are not defined and the calculator says so instead of printing infinity.
R's fisher.test prints a different odds ratio, the conditional maximum likelihood estimate. For this table it is 1.6442 against the sample 1.6446. Both are legitimate; just say which one you report.
Orientation and R
R fills a matrix by column, so matrix(c(61, 939, 38, 962), 2) puts 939 in the bottom-left cell, not the top-right. The χ² value does not change when a table is transposed, but the odds ratio direction and one-sided tests do. The R code under the result uses byrow = TRUE so it matches the grid exactly.
Common questions
Should I use the Yates correction?
Most current advice says no for analysis, but it is what R and SciPy print by default. Report whichever you used, by name.
Can phi be negative?
Yes. The signed phi shows direction. Its absolute value equals the square root of χ² over N.
What if a cell is zero?
The chi-square tests still run if no row or column total is zero. The sample odds ratio and relative risk are then not defined, and Fisher's exact test is the safer choice.
Sources
- R source code, chisq.test (stats package) checked November 21, 2026
- SciPy documentation: scipy.stats.chi2_contingency checked November 21, 2026
- Campbell I. (2007). Chi-squared and Fisher-Irwin tests of two-by-two tables with small sample recommendations. Statistics in Medicine 26:3661-3675 checked November 21, 2026