Contingency Table Calculator
Analyze categorical data relationships with the chi-square test of independence. Supports any R×C contingency table with expected frequencies, standardized residuals, Cramér's V effect size, animated mosaic plot, residual heatmap, and step-by-step solutions.
Your ad blocker is preventing us from showing ads
MiniWebtool is free because of ads. If this tool helped you, please support us by going Premium (ad‑free + faster tools), or allowlist MiniWebtool.com and reload.
- Allow ads for MiniWebtool.com, then reload
- Or upgrade to Premium (ad‑free)
About Contingency Table Calculator
The Contingency Table Calculator performs the chi-square test of independence on any R×C contingency table (cross-tabulation). Enter your observed frequencies to test whether two categorical variables are statistically associated. Get detailed results including expected frequencies, adjusted standardized residuals, Cramér's V effect size, cell contribution analysis, interactive mosaic plots, residual heatmaps, chi-square distribution curves, and a complete step-by-step solution.
How to Use the Contingency Table Calculator
- Set table dimensions — choose the number of rows and columns for your contingency table. The default is a 2×2 table, but you can analyze tables up to 10×10 using the dropdown selectors.
- Enter observed frequencies — type the observed count for each cell directly into the interactive grid. Alternatively, switch to "Text Input" mode to paste tab-separated or comma-separated data. All values must be non-negative whole numbers.
- Add labels (optional) — enter row and column category labels separated by commas. Labels make the output tables and charts easier to interpret. For example, "Male, Female" for rows and "Yes, No" for columns.
- Set significance level — choose your desired α level. The most common choice is 0.05 (95% confidence). Smaller α values (0.01, 0.001) require stronger evidence to declare significance.
- Analyze results — click "Analyze Contingency Table" to see the chi-square statistic, p-value, effect size measures, visualizations, and step-by-step solution.
What Is a Contingency Table?
A contingency table (also called a cross-tabulation, crosstab, or two-way frequency table) displays the joint frequency distribution of two categorical variables. Each row represents one category of the first variable, each column represents one category of the second variable, and each cell contains the count of observations falling into that specific combination. Contingency tables are the foundation for many categorical data analysis methods, including the chi-square test, Fisher's exact test, and log-linear models.
The Chi-Square Test of Independence
The chi-square (χ²) test of independence determines whether there is a statistically significant association between two categorical variables. It works by comparing the observed cell frequencies with the frequencies that would be expected if the variables were independent.
Where Oᵢⱼ is the observed frequency in cell (i,j), and Eᵢⱼ is the expected frequency calculated as:
The degrees of freedom for the test are (r − 1) × (c − 1), where r is the number of rows and c is the number of columns. A larger χ² value indicates a greater discrepancy between observed and expected frequencies, suggesting the variables are associated.
Cramér's V — Measuring Effect Size
While the p-value tells you whether an association exists, Cramér's V tells you how strong it is. Cramér's V ranges from 0 (no association) to 1 (perfect association) and is calculated as:
Where N is the total sample size and k is the smaller of the number of rows or columns. The interpretation of Cramér's V depends on the degrees of freedom:
| Effect Size | df* = 1 | df* = 2 | df* ≥ 3 |
|---|---|---|---|
| Negligible | < 0.10 | < 0.07 | < 0.06 |
| Small | 0.10 – 0.30 | 0.07 – 0.21 | 0.06 – 0.17 |
| Medium | 0.30 – 0.50 | 0.21 – 0.35 | 0.17 – 0.29 |
| Large | ≥ 0.50 | ≥ 0.35 | ≥ 0.29 |
*df* refers to min(rows, columns) − 1
Understanding Standardized Residuals
Adjusted standardized residuals reveal which specific cells contribute most to a significant chi-square result. A residual of +2.5 in a cell means that cell has 2.5 standard deviations more observations than expected under independence. Key thresholds are:
- |r| > 1.96 — significantly different from expected (p < 0.05)
- |r| > 2.58 — highly significantly different from expected (p < 0.01)
- Positive residual — more observations than expected in that cell
- Negative residual — fewer observations than expected in that cell
When to Use the Chi-Square Test
- Categorical data — both variables must be categorical (nominal or ordinal)
- Independent observations — each observation should be counted only once
- Adequate sample size — at least 80% of expected counts should be ≥ 5, and no expected count should be below 1
- Random sampling — observations should come from a random sample of the population
If expected counts are too low, consider combining categories, using Fisher's exact test (for 2×2 tables), or using exact tests or Monte Carlo simulation for larger tables.
Chi-Square Test vs. Fisher's Exact Test
- The chi-square test uses a large-sample approximation; Fisher's test computes exact probabilities
- Fisher's test is preferred for 2×2 tables with small expected counts (< 5)
- The chi-square test generalizes naturally to R×C tables of any size
- For large samples, both tests produce very similar results
FAQ
What is a contingency table?
A contingency table (also called a cross-tabulation or crosstab) is a table that displays the frequency distribution of two or more categorical variables. Each cell shows the count of observations that fall into a specific combination of categories. It is the foundation for testing whether the variables are independent or associated using the chi-square test.
What is the chi-square test of independence?
The chi-square test of independence determines whether there is a statistically significant association between two categorical variables in a contingency table. It compares observed cell frequencies with expected frequencies calculated under the assumption that the variables are independent. A large chi-square statistic relative to the degrees of freedom suggests the variables are associated.
What is Cramér's V and how do I interpret it?
Cramér's V is an effect size measure for the chi-square test, ranging from 0 (no association) to 1 (perfect association). For 2×2 tables, values below 0.10 are negligible, 0.10–0.30 is a small effect, 0.30–0.50 is medium, and above 0.50 is large. For larger tables the thresholds are proportionally lower. Unlike the p-value, Cramér's V measures the strength of association, not just whether it exists statistically.
What are standardized residuals in a contingency table?
Adjusted standardized residuals show how much each cell deviates from what would be expected under independence. Values greater than +1.96 or less than −1.96 indicate a significant departure at the 0.05 level. Positive residuals mean more observations than expected in that cell; negative residuals mean fewer. They help pinpoint which specific cell combinations drive the overall association.
When should I not use the chi-square test?
The chi-square test may be unreliable when expected frequencies are very low — specifically when more than 20% of expected counts fall below 5, or any expected count is below 1. For 2×2 tables with small samples, Fisher's exact test is preferred. The test also requires independent observations, so it should not be used with paired, matched, or repeated-measures data.
Reference this content, page, or tool as:
"Contingency Table Calculator" at https://MiniWebtool.com// from MiniWebtool, https://MiniWebtool.com/
by miniwebtool team. Updated: 2026-04-15
You can also try our AI Math Solver GPT to solve your math problems through natural language question and answer.