Chi-Square Calculator
Enter a table of counts to test whether its rows and columns are related, or a list of observed counts to test whether they match what you expected. You get the chi-square statistic, the degrees of freedom, the p-value, the critical value, the expected counts, standardized residuals and, for a table, Cramer's V as a measure of effect size. A 2 by 2 table can use the Yates continuity correction. Everything runs in your browser.
The result is statistically significant at the 0.05 level: the rows and columns are related by more than chance would usually give.
| 762 | 327 | 468 |
| 484 | 239 | 477 |
| 703.7 | 319.6 | 533.7 |
| 542.3 | 246.4 | 411.3 |
| 2.199 | 0.4114 | -2.843 |
| -2.505 | -0.4686 | 3.239 |
The chi-square test compares counts you observed with the counts you would expect if nothing were going on. The statistic adds up (observed minus expected) squared, divided by expected, over every cell, and the p-value is the chance of a total at least that large by luck alone. A test of independence asks whether the rows and columns of a table are related, and the degrees of freedom are (rows minus 1) times (columns minus 1). Goodness of fit asks whether one set of counts matches expected shares. The test is reliable when every expected count is about 5 or more. The residuals show which cells differ most, and values beyond about 2 stand out. The example is a table from R's documentation. Everything is worked out in your browser.
Related Tools
[5 suggestions]t-Test Calculator: One Sample, Two Sample and Paired
Run a one-sample, Welch, pooled or paired t-test on your data and get the t value, degrees of freedom, p-value, confidence interval and effect size.
Student ToolsBinomial Probability Calculator
Find the chance of exactly, at most or at least k successes in n trials, with the mean, standard deviation and a chart of the whole distribution.
Math & MoneySample Size Calculator
Find how many survey responses you need for a confidence level and margin of error, or the margin of error a sample gives.
Math & MoneyZ-Score Calculator
Turn a value into a z-score, a z-score into probabilities and percentiles, or a percentile back into a z-score, using the standard normal distribution.
Math & MoneyConfidence Interval Calculator
Find a confidence interval for a mean (from summary numbers or raw data) or a proportion, with the t value and margin of error.
Math & MoneyAbout the Chi-Square Calculator
The chi-square test compares the counts you observed with the counts you would expect if there were no pattern. For each cell it takes the difference between observed and expected, squares it, divides by the expected count and adds the results. A large total means the data sit far from what chance would give. In a test of independence the expected count for a cell is its row total times its column total, divided by the grand total, and the degrees of freedom are (rows minus 1) times (columns minus 1). In a goodness of fit test the expected counts come from shares you supply, such as 9:3:3:1, or from equal shares, and the degrees of freedom are the number of categories minus 1, less any parameters estimated from the data. The p-value is the upper tail of the chi-square distribution, computed from the regularized incomplete gamma function so that very small values keep their digits. As a check, the example table from R's documentation, 762, 327 and 468 against 484, 239 and 477, gives chi-square 30.07 with 2 degrees of freedom and p = 2.954e-07, and counts of 20, 15 and 25 against equal shares give 2.5, 2 degrees of freedom and p = 0.2865. Mendel's 315, 101, 108 and 32 peas against 9:3:3:1 give 0.47 and p = 0.925. The test is reliable when every expected count is about 5 or more, and the calculator warns when it is not. Cramer's V is the square root of chi-square divided by n times the smaller of rows minus 1 and columns minus 1.
What is a chi-square test used for?▾
It tests whether counts in categories differ from what you expected. A test of independence asks whether two categorical variables are related, such as gender and party. A goodness of fit test asks whether one set of counts matches expected shares, such as whether a die is fair.
How do I read the p-value?▾
It is the chance of a chi-square value at least this large if the variables were really unrelated, or the counts really followed the expected shares. A p-value below your significance level, commonly 0.05, is evidence against that assumption. It does not measure how big the effect is, so look at Cramer's V too.
What are the degrees of freedom?▾
For a table of counts it is (rows minus 1) times (columns minus 1). For goodness of fit it is the number of categories minus 1, minus the number of parameters you estimated from the data. The degrees of freedom decide which chi-square distribution the p-value comes from.
What if some expected counts are below 5?▾
The chi-square approximation becomes unreliable. Combine small categories where that makes sense, collect more data, or use an exact test such as Fisher's exact test for a 2 by 2 table. The calculator counts the cells under 5 and warns you.
Is my data uploaded?▾
No. The calculation runs in your browser and nothing you enter is sent anywhere.