χ² Chi-Square Test Calculator
Compute chi-square statistic, expected frequencies, degrees of freedom, and p-value for a 2×2 to 4×4 contingency table.
Expected Frequencies
What is a Chi-Square Test?
The chi-square (χ²) test is a statistical hypothesis test used to determine whether an observed distribution of categorical data differs significantly from a theoretically expected distribution. In the most common application — the chi-square test of independence — it tests whether two categorical variables measured on the same sample are statistically associated or independent of one another. The test was developed by Karl Pearson in 1900 and remains one of the most widely used statistical tests in the social sciences, life sciences, market research, and quality control. Its strength lies in its applicability to categorical data, which cannot be analysed with t-tests or ANOVA that require continuous variables.
The test works by comparing observed cell frequencies in a contingency table with the expected frequencies that would arise if the two variables were completely independent. Expected frequency for each cell is calculated as (row total × column total) / grand total — the value you would expect if knowing one variable gave you no information about the other. The chi-square statistic is the sum of (Observed − Expected)² / Expected across all cells. Larger values of χ² indicate greater discrepancy between what was observed and what independence would predict, with the p-value quantifying the probability of observing a discrepancy this large or larger by chance alone if the null hypothesis of independence were true.
Degrees of freedom (df) in a chi-square test of independence equal (rows − 1) × (columns − 1), reflecting the number of cells that are free to vary given the fixed row and column totals. The test requires minimum expected cell frequencies (typically ≥ 5 in at least 80% of cells) to ensure the chi-square approximation is valid — a condition worth checking before interpreting results. When expected frequencies are very small, Fisher's exact test provides a more accurate alternative. Effect size for chi-square is commonly reported as Cramér's V, which scales the χ² statistic to a 0–1 range that is comparable across different table sizes.
Chi-Square Formula
How to Perform a Chi-Square Test
-
1Set Table SizeSelect the number of rows and columns that match your data categories.
-
2Enter Observed CountsFill in each cell with the frequency count you observed in your data.
-
3Review Expected FrequenciesThe calculator shows what frequencies would be expected if the variables were independent.
-
4Interpret the ResultIf p < 0.05, reject H₀ — there is a statistically significant association between the variables.
How the Chi Square Calculator Works
Formula, assumptions, and calculation steps for this statistics tool.
Methodology
Statistics calculators organize sample data, apply the selected descriptive or inferential formula, and report the statistic with interpretation.
Calculation Steps
- Enter raw values or summary statistics.
- Clean separators and count the sample size.
- Apply the relevant statistic, probability, or confidence formula.
- Display the result with context such as degrees of freedom, percentile, or strength.
Assumptions and Limits
- Samples should be representative of the population being studied.
- Normality or independence assumptions apply only where the selected method requires them.
- Rounded results may differ slightly from spreadsheet software.
Frequently Asked Questions
The chi-square test of independence determines whether two categorical variables are associated. For example, whether treatment type and recovery outcome are related, or whether gender and product preference are independent.
H₀ states that the two categorical variables are independent — knowing one variable tells you nothing about the other. A significant result means the variables are associated.
Expected frequencies are what you would expect in each cell if H₀ were true (complete independence). They are calculated from the row totals, column totals, and grand total.
The test requires that expected frequencies are ≥ 5 in at least 80% of cells, and no cell has an expected frequency < 1. If these assumptions are violated, consider Fisher's exact test instead.
Yates' continuity correction adjusts the chi-square formula for 2×2 tables to reduce overestimation of significance. It subtracts 0.5 from |O−E| before squaring, making the test more conservative.
Real-World Applications
Common Mistakes
Chi-Square Critical Values at Common α Levels
| df | α = 0.10 | α = 0.05 | α = 0.01 | Table Context |
|---|---|---|---|---|
| 1 | 2.706 | 3.841 | 6.635 | 2×2 table |
| 2 | 4.605 | 5.991 | 9.210 | 2×3 or 3×2 table |
| 3 | 6.251 | 7.815 | 11.345 | 2×4 or 4×2 table |
| 4 | 7.779 | 9.488 | 13.277 | 3×3 table |
| 9 | 14.684 | 16.919 | 21.666 | 4×4 table |
References
- Pearson, K. On the Criterion that a Given System of Deviations from the Probable in the Case of a Correlated System of Variables is Such that it can be Reasonably Supposed to have Arisen from Random Sampling. Philosophical Magazine, 1900.
- Field, A. Discovering Statistics Using IBM SPSS Statistics, 5th ed. SAGE, 2018.
- Montgomery, D. C. Design and Analysis of Experiments, 10th ed. Wiley, 2020.
- Cohen, J. Statistical Power Analysis for the Behavioral Sciences, 2nd ed. Lawrence Erlbaum, 1988.
- Agresti, A. Categorical Data Analysis, 3rd ed. Wiley, 2013.
Related Calculators
Browse all Statistics calculators →T-Test Calculator
Perform one-sample, two-sample, and paired t-tests with p-value and confidence interval.
ANOVA Calculator
Perform one-way ANOVA test to compare means across multiple groups.
Normal Distribution Calculator
Calculate probabilities and percentiles for the normal (Gaussian) distribution.