Contingency Table Calculator

Enter counts for your 2×2 table — Cell A, Cell B, Cell C, and Cell D — along with optional row and column labels. The Contingency Table Calculator runs either a Chi-square test or Fisher's exact test and returns the p-value, odds ratio, and relative risk so you can determine whether an association exists between your two categorical factors.

Count of Group 1 subjects with Outcome 1

Count of Group 1 subjects with Outcome 2

Count of Group 2 subjects with Outcome 1

Count of Group 2 subjects with Outcome 2

Use Fisher's exact test when any expected cell count is less than 5.

Results

P-Value

--

Test Statistic (χ²)

--

Odds Ratio

--

Relative Risk

--

Interpretation

--

Total N

--

Cell Count Distribution

Results Table

Frequently Asked Questions

What is a contingency table?

A contingency table (also called a cross-tabulation or crosstab) is a grid that displays the frequency distribution of two or more categorical variables. A 2×2 contingency table arranges subjects into four cells based on two binary factors — for example, exposed vs. unexposed and diseased vs. not diseased. It allows you to examine whether the two factors are statistically associated.

When should I use Chi-square vs. Fisher's exact test?

Use the Chi-square test when all expected cell frequencies are 5 or greater and your total sample size is reasonably large. Use Fisher's exact test when any expected cell count falls below 5, or when your total sample size is small. Fisher's test is computationally more demanding but is always valid for 2×2 tables regardless of sample size.

Should I choose a one-tailed or two-tailed p-value?

A two-tailed test is almost always recommended because it tests whether the association goes in either direction — Group 1 could have a higher or lower rate of Outcome 1 than Group 2. Use a one-tailed test only if you had a strong directional hypothesis before collecting data, and even then, reviewers and journals often prefer two-tailed results.

What does the p-value tell me?

The p-value is the probability of observing results at least as extreme as yours if there were truly no association between the two factors. A p-value below 0.05 is conventionally considered statistically significant, suggesting the observed association is unlikely to be due to chance alone. However, statistical significance does not imply practical importance.

How do I interpret the odds ratio?

The odds ratio (OR) compares the odds of Outcome 1 occurring in Group 1 versus Group 2. An OR of 1 means no difference. An OR greater than 1 means Group 1 has higher odds; less than 1 means lower odds. For example, an OR of 2.5 means Group 1 subjects have 2.5 times the odds of experiencing Outcome 1 compared to Group 2 subjects.

What is relative risk, and how does it differ from odds ratio?

Relative risk (RR), or risk ratio, directly compares the probability (proportion) of Outcome 1 in Group 1 versus Group 2. Unlike the odds ratio, relative risk is more intuitive and easier to communicate. However, it is only appropriate for prospective or cross-sectional study designs — for case-control studies, the odds ratio is the correct measure.

What are the assumptions of a 2×2 contingency table analysis?

Key assumptions include: observations are independent (each subject appears in only one cell), the data represent counts (not percentages or proportions entered directly), and for Chi-square the expected frequency in each cell should be at least 5. Violating independence — such as using paired or repeated-measures data — requires different tests like McNemar's test.

Can I use this calculator for tables larger than 2×2?

This calculator is designed specifically for 2×2 contingency tables with two binary factors. For larger tables (e.g., 3×2 or 3×3), you would need a more general Chi-square test of independence that handles multiple rows and columns. Tools like statistical software (R, SPSS, Stata) or dedicated online calculators for R×C tables handle those cases.

More Statistics Tools