Chi-Square Test Calculator (2x2)

Chi-square statistic (2x2)2.20
p-value (df = 1)0.1382
Effect size (phi coefficient)0.10
Expected count, top-left cell35.00
How this was calculated
  1. Expected count for the top-left cell if the two variables were independent: (100 × 70) ÷ 200 = 35.00.
  2. Chi-square: 200 × (40 × 70 − 60 × 30)² ÷ 91,000,000 = 2.20.
  3. With 1 degree of freedom, the p-value is 0.1382. Below 0.05 the association is conventionally called statistically significant; the test needs expected counts of about 5 or more per cell to be trustworthy.

This chi-square test calculator evaluates a 2x2 contingency table to determine whether the row and column variables are independent. Enter the four counts labeled a, b, c and d, and the tool returns the chi-square statistic, degrees of freedom, p-value, expected counts and the phi coefficient. The phi coefficient, the square root of chi-square divided by N, measures effect size for a 2x2 table on the same -1 to 1 scale as a correlation. For example, the table 40, 60 / 30, 70 gives chi-square 2.20 with p = 0.1382, which is not significant at the 0.05 level. The table 85, 15 / 60, 40 gives chi-square 15.67 with p = 0.0001, a strong departure from independence. A perfectly balanced table of 25, 25 / 25, 25 gives chi-square 0.00 with p = 1.0000.

The chi-square test is the accepted standard for testing independence in a 2x2 table because it compares observed counts directly against the counts expected under independence, yielding one clear statistic with 1 degree of freedom. For a 2x2 table the statistic can be written directly as N(ad − bc)² ÷ ((a+b)(c+d)(a+c)(b+d)). The test is trustworthy only when expected counts are reasonably large; the usual rule of thumb is at least about 5 per cell, and for small samples Fisher's exact test is preferred. This page shows the formula, step-by-step workings, worked examples and sources so you can verify every result yourself.

Worked examples

A weak association

Primary result: 2.20 — p = 0.1382, not significant at the 0.05 level. (40 · 60 · 30 · 70)

Chi-square statistic (2x2)2.20
p-value (df = 1)0.1382
Effect size (phi coefficient)0.10
Expected count, top-left cell35.00

A strong association

Primary result: 15.67 — p = 0.0001, a clear departure from independence. (85 · 15 · 60 · 40)

Chi-square statistic (2x2)15.67
p-value (df = 1)0.0001
Effect size (phi coefficient)0.28
Expected count, top-left cell72.50

Perfectly independent

Primary result: 0.00 — identical row proportions give p = 1.0000. (25 · 25 · 25 · 25)

Chi-square statistic (2x2)0.00
p-value (df = 1)1.0000
Effect size (phi coefficient)0.00
Expected count, top-left cell25.00

What the chi-square test of independence asks

The chi-square test of independence asks a straightforward question: are the row variable and the column variable in a contingency table related, or do they operate independently of each other? To answer that, the test compares what you actually observed in your data against what you would expect to see if the two variables had no connection at all. Those expected counts are calculated by spreading the total sample across the table according to the row and column totals, assuming no association. If the observed counts match the expected counts closely, there is little evidence of a relationship. If they diverge sharply, that is a sign the variables may be dependent.

For a 2x2 contingency table the chi-square statistic can be written directly as N(ad − bc)² ÷ ((a+b)(c+d)(a+c)(b+d)), with 1 degree of freedom, where a, b, c, and d are the four cell counts and N is the grand total. This formula captures the heart of the test in a compact way: the product difference (ad − bc) measures how far the observed pattern strays from the pattern expected under independence. A chi-square test calculator uses this statistic to produce a p-value, which tells you how likely such a departure would be if the variables were truly independent.

Consider a table with cell counts of 40, 60 in the first row and 30, 70 in the second. The expected count in the top-left cell under independence is 35.00, and the test returns a chi-square statistic of 2.20 with p = 0.1382 — not significant at the 0.05 level. The observed counts differ somewhat from what independence would predict, but not enough to rule out chance. By contrast, a table with counts of 85, 15 and 60, 40 gives a chi-square of 15.67 with p = 0.0001, a strong departure from independence. Here the observed pattern is very unlikely to arise if the two variables have no real connection. At the extreme, a perfectly balanced table of 25, 25 and 25, 25 yields a chi-square of 0.00 with p = 1.0000, since the observed counts match the expected counts exactly.

To gauge the strength of an association rather than just its existence, the phi coefficient provides a useful effect size measure for a 2x2 table. It is the square root of chi-square divided by N, and it falls on the same −1 to 1 scale as a correlation, making the result easier to interpret. Keep in mind that the chi-square test is trustworthy only when expected counts are reasonably large — the usual rule of thumb is at least about 5 per cell. For small samples, Fisher's exact test is preferred because it does not rely on the same large-sample approximation.

Worked examples

The three tables below show how a chi-square test calculator handles different patterns of data. Each table is laid out as two rows and two columns, with cells labeled a, b, c, and d reading left to right, top to bottom. For every 2x2 contingency table the chi-square statistic can be written directly as N(ad − bc)² ÷ ((a+b)(c+d)(a+c)(b+d)), with 1 degree of freedom, and it tests whether the row and column variables are independent. The phi coefficient, the square root of chi-square divided by N, measures effect size for a 2x2 table on the same -1 to 1 scale as a correlation.

The first example, 40, 60 / 30, 70, produces a chi-square statistic of 2.20 with a p-value of 0.1382. Because 0.1382 is above the standard 0.05 threshold, the result is not significant. The expected count in the top-left cell under independence is 35.00, and the observed value of 40 is close enough that the difference is plausibly due to chance. The second example, 85, 15 / 60, 40, gives chi-square 15.67 with p = 0.0001 — a strong departure from independence. Here the observed counts diverge sharply from what independence would predict, so the calculator would flag a statistically significant association.

The third example, the perfectly balanced table 25, 25 / 25, 25, gives chi-square 0.00 with p = 1.0000. Every cell exactly matches its expected count under independence, so there is no evidence of any association between the row and column variables. Together these three cases span the range you are likely to encounter: a clear non-significant result, a strong significant result, and a null result with no detectable relationship.

One important caveat applies to all three examples. The test is trustworthy only when expected counts are reasonably large — the usual rule of thumb is at least about 5 per cell. For small samples, Fisher's exact test is preferred. The first table's expected top-left count of 35.00 is well above that threshold, but a chi-square test calculator will warn you or refuse to produce a result when any expected count falls below it.

Table (a, b / c, d)Chi-squarep-valueVerdict
40, 60 / 30, 702.200.1382Not significant at the 0.05 level; expected top-left count is 35.00
85, 15 / 60, 4015.670.0001Strong departure from independence
25, 25 / 25, 250.001.0000Perfectly balanced; no evidence of association
Before relying on any p-value from a 2x2 chi-square test, confirm that every expected cell count is at least about 5. If not, use Fisher's exact test instead.

Reading the p-value and phi together

A p-value tells you whether an observed pattern is surprising under independence, but it says nothing about how strong that pattern is. The chi-square statistic grows with sample size, so a huge sample can make a trivial difference look highly significant. The phi coefficient restores proportion by measuring effect size on the same -1 to 1 scale as a correlation, giving you a sense of magnitude that the p-value alone cannot provide.

Consider what happens when you run the same small association through a chi-square test calculator with a much larger sample. A table of 40, 60 over 30, 70 produces a chi-square of 2.20 with p = 0.1382, which is not significant at the 0.05 level. The expected count in the top-left cell under independence is 35.00, and the observed 40 is not far from that. Now compare that to the table 85, 15 over 60, 40, which gives chi-square 15.67 with p = 0.0001, a strong departure from independence. The first table has 200 observations; the second has 200 as well, yet the second shows a far larger gap between observed and expected counts, and the p-value reflects that gap.

The phi coefficient helps you see why. For a 2x2 contingency table the chi-square statistic can be written directly as N(ad − bc)² ÷ ((a+b)(c+d)(a+c)(b+d)), with 1 degree of freedom, testing whether the row and column variables are independent. Phi is the square root of chi-square divided by N. A perfectly balanced table such as 25, 25 over 25, 25 gives chi-square 0.00 with p = 1.0000, and phi would be 0 as well. When chi-square is large relative to N, phi moves away from 0 and tells you the association is not just statistically detectable but practically meaningful.

This distinction matters most with big data. If a study of 50,000 people finds a p-value below 0.001 for a relationship that barely shifts observed counts from expected counts, the result is significant in the statistical sense but the effect size may be close to zero. Reading p and phi together prevents you from confusing a tiny but real difference with an important one. The p-value answers whether chance could plausibly explain what you see; phi answers how far from independence the data actually sit.

One caveat before you trust either number: the test is reliable only when expected counts are reasonably large. The usual rule of thumb is at least about 5 per cell. For small samples, Fisher's exact test is preferred because it does not rely on the large-sample approximation that the chi-square test requires.

Significance is not importance. A large sample can push a trivial association past the 0.05 threshold, while phi tells you whether the association is strong enough to matter.

Limits of the 2x2 chi-square test

A chi-square test calculator for a 2x2 table is a fast way to judge whether two categorical variables are independent, but the result is only as trustworthy as the data behind it. The statistic has one degree of freedom, and the formula N(ad − bc)² ÷ ((a+b)(c+d)(a+c)(b+d)) assumes that each expected count is reasonably large. The usual rule of thumb is at least about 5 per cell. When any expected count falls below that threshold, the chi-square approximation becomes unreliable, and Fisher's exact test is preferred for small samples. This is why a table with a large total N but a very small cell can still be problematic, and why a significant-looking result from sparse data should be checked with a more appropriate method.

The 2x2 chi-square test also assumes the observations are independent. If the data are paired or matched, such as the same subjects measured before and after an intervention, the standard chi-square test is the wrong tool. In that situation, McNemar's test is the correct choice because it focuses on the discordant pairs rather than the full cross-tabulation. Using a standard chi-square test calculator on paired data can produce misleading conclusions about whether a change has occurred.

A separate issue is the Yates continuity correction. For 2x2 tables with one degree of freedom, the chi-square distribution is continuous but the data are discrete, and Yates proposed a correction to reduce the resulting overstatement of significance. The debate is long-running: some analysts apply it by default for 2x2 tables, while others argue it is too conservative and can mask real effects, particularly with moderate sample sizes. Many calculators offer both the corrected and uncorrected results so users can compare them. Knowing which value a calculator reports is essential before interpreting the p-value.

None of these limits change what the test measures. The phi coefficient, the square root of chi-square divided by N, still measures effect size for a 2x2 table on the same -1 to 1 scale as a correlation. A table such as 85, 15 / 60, 40 gives chi-square 15.67 with p = 0.0001, a strong departure from independence, while 40, 60 / 30, 70 gives chi-square 2.20 with p = 0.1382, not significant at the 0.05 level, and the perfectly balanced 25, 25 / 25, 25 gives chi-square 0.00 with p = 1.0000. These results are meaningful only when the data meet the test's assumptions.

Before relying on a 2x2 chi-square result, confirm that expected counts are at least about 5 per cell and that the data are not paired. If either condition fails, use Fisher's exact test or McNemar's test instead.

FAQs

How is the chi-square statistic calculated for a 2x2 table?

The formula is N(ad − bc)² divided by the product of the four margin totals. In the first example, 200 × 1000² ÷ 91,000,000 = 2.20. Here, N is the total sample size, and a, b, c, d are the four cell counts. This statistic measures how far the observed counts deviate from the counts expected under independence.

How many degrees of freedom does a 2x2 table have?

A 2x2 table has one degree of freedom. The formula is (rows − 1) × (columns − 1), which equals 1 × 1 = 1. Degrees of freedom determine which chi-square distribution is used to obtain the p-value. With one degree of freedom, the chi-square distribution has a distinct shape used to assess statistical significance.

What p-value is significant?

Conventionally, a p-value below 0.05 is considered significant. The first example's p-value of 0.1382 is not significant, meaning there is insufficient evidence to reject independence. The second example's p-value of 0.0001 is highly significant, indicating strong evidence of an association between the two variables in the table.

What is the phi coefficient?

The phi coefficient is the square root of chi-square over N. It serves as an effect-size measure for 2x2 tables and is interpreted much like a correlation. Values range from 0 to 1, with larger values indicating a stronger association. Phi helps you understand the magnitude of the relationship, not just whether it is statistically significant.

When should I use Fisher's exact test instead?

Use Fisher's exact test when any expected count is small, roughly below 5. In such cases, the chi-square approximation may be unreliable. Fisher's test computes the exact probability of the observed data under the null hypothesis rather than relying on an approximation. This makes it better suited for small samples or sparse tables.

Does a significant chi-square prove causation?

No. A significant chi-square result shows an association beyond chance in the sample, but it does not prove causation. Confounding variables, study design, and the context of the data all play a role in determining whether one variable truly causes another. Chi-square tests only detect whether variables are related, not why.

Sources

Related calculators

One-Sample T-Test Calculator
Test a sample mean against a hypothesised population mean: the t statistic, standard error, degrees of freedom, the critical value from the t table, and the verdict at your alpha.
Odds Ratio Calculator
Odds ratio and relative risk from a 2x2 table (exposed/unexposed × outcome/no outcome), with the 95% confidence interval for the odds ratio by the log method.
Z-Score Calculator
The z-score of any value in a normal distribution, its percentile, and the share of values above and below it — the standardisation behind test scores and quality control.
Confidence Interval Calculator
The range around a sample mean or a sample proportion at 90%, 95% or 99% confidence, with the standard error and margin of error shown step by step.