Enter four non-negative counts for a 2×2 table. The calculator returns totals, expected counts, chi-square statistics, odds ratio, relative risk, and phi coefficient.
What is a contingency table?
A contingency table (also called a cross-tabulation or crosstab) is a compact way to summarize the relationship between two categorical variables. In a 2×2 table, each variable has two categories, and each cell contains a count of observations that fall into a specific row-column combination.
For example, you might compare treatment status (treated vs. untreated) with outcome status (recovered vs. not recovered). The resulting four counts can reveal whether the variables appear to be associated or independent.
How to use this contingency table calculator
Step 1: Name your categories
Use the label fields to define meaningful row and column names. This makes the output easier to interpret and report in research notes, lab reports, or business analyses.
Step 2: Enter the four counts
Fill in cells a, b, c, d:
- a = Row 1 + Column 1
- b = Row 1 + Column 2
- c = Row 2 + Column 1
- d = Row 2 + Column 2
All values should be non-negative counts. Decimals are accepted by the calculator, but whole numbers are most common in practice.
Step 3: Review statistical output
After calculation, you get observed totals, expected counts (assuming independence), Pearson chi-square, Yates-corrected chi-square, and effect-size metrics like odds ratio and relative risk.
Understanding the key metrics
Pearson chi-square (χ²)
This statistic compares observed counts to expected counts under the assumption that row and column variables are independent. A large χ² suggests stronger evidence of association.
Approximate p-value (df = 1)
The p-value quantifies how surprising your table would be if there were truly no association. Smaller p-values provide stronger evidence against independence.
Odds ratio (OR)
The odds ratio compares odds across rows. In medical and social science contexts, OR greater than 1 often suggests higher odds of the outcome in Row 1 relative to Row 2.
Relative risk (RR)
Relative risk compares probabilities (risk) directly. RR is often easier to explain than OR, especially in cohort-style settings.
Phi coefficient (φ)
Phi is a correlation-like effect size for 2×2 tables, ranging from -1 to +1 in ideal conditions. Values near zero indicate weak association.
When to be careful
- If expected counts are very small (especially below 5), chi-square approximations may be less reliable.
- For small samples, Fisher’s exact test is often preferred.
- Association does not imply causation; study design and confounding factors still matter.
- Zero cells can create infinite OR values; corrected OR estimates may be reported.
Practical use cases
- A/B testing conversions (converted vs. not converted by variant)
- Clinical studies (treatment group by outcome group)
- Survey analysis (response category by demographic group)
- Quality control (pass/fail by production line)
Quick interpretation checklist
- Check sample size and expected counts.
- Look at effect size (OR, RR, phi), not just p-value.
- Ensure variable definitions are clear and mutually exclusive.
- Report both the table and the statistical summary.
Use this page as a fast first-pass analysis tool for 2×2 categorical data. For publishable work, pair these results with confidence intervals and a method section that documents assumptions.