When is the chi-square test not valid?
When the expected counts are too small for the chi-square distribution to approximate the statistic's behaviour — Cochran's rule: invalid when any expected count falls below 1, or when fewer than 80% of cells have an expected count of 5 or more. It is also the wrong test at any sample size when observations are paired or repeated. This calculator checks the rule on your table live; when it fails, a 2×2 table belongs to Fisher's exact test and a larger one to the Freeman–Halton extension.
How do you calculate chi-square by hand?
Four steps. (1) Total the rows, the columns and the grand total. (2) Compute each cell's expected count: row total × column total ÷ grand total (for goodness of fit, total × expected proportion). (3) For every cell compute (O−E)²/E and add them up — that sum is χ². (4) Take the degrees of freedom — (rows − 1) × (columns − 1), or categories − 1 for goodness of fit — and read the p-value from the chi-square distribution. The worked examples on this page carry out every step in numbers.
What are expected counts in a chi-square test?
The counts a cell would hold, on average, if the null hypothesis were true. For independence they come from the table's own margins — row total × column total ÷ grand total — so the drug-trial table's top-left cell expects 10 × 9 ÷ 16 = 5.625. For goodness of fit they come from the claimed proportions: total × expected proportion. Expected counts need not be whole numbers, and they, not the observed counts, are what Cochran's validity rule inspects.
What does a chi-square p-value mean?
It is the probability, computed under the null hypothesis, of obtaining a χ² statistic at least as large as the one your data produced — the probability of counts at least this far from expectation arising by chance alone. It is not the probability that the null hypothesis is true, not the probability that your result is a fluke in isolation, and not a measure of how strong the association is: that is Cramér's V's job. Because it comes from the chi-square distribution rather than an enumeration, it is an approximation whose accuracy the validity verdict on this page audits.
When do you use a chi-square test?
When both variables are categorical, the observations are independent counts, and you want to know whether the pattern in the table departs from a stated null: two variables associated (independence), distributions matching across groups (homogeneity), or counts fitting claimed proportions (goodness of fit). Use it when expected counts are healthy enough for the approximation — Cochran's rule — and reach for an exact test when they are not, or a paired test such as McNemar's when the same subjects appear twice.
How do you calculate degrees of freedom for chi-square?
For a test of independence or homogeneity on an r×c table, df = (rows − 1) × (columns − 1): 1 for 2×2, 2 for 2×3, 4 for 3×3. The logic is that once the margins are fixed, only that many cells can be filled freely before the rest are forced. For goodness of fit there are no margins, only the total, so df = categories − 1: six categories give 5.
What is the critical value of chi-square at 0.05?
It depends on the degrees of freedom: 3.841 at df = 1, 5.991 at df = 2, 7.815 at df = 3, 9.488 at df = 4 and 11.070 at df = 5, rising to 18.307 at df = 10. Your χ² statistic must exceed the critical value for its df before the p-value can drop below 0.05. The calculator card carries the full table for df 1–10 at both α = 0.05 and α = 0.01 — at df = 1 the 0.01 value is 6.635.
What is the difference between the chi-square tests of independence, homogeneity and goodness of fit?
The statistic is identical; the study design and the source of the expected counts differ. Independence: one sample cross-classified by two variables, expected counts from the margins, asking 'are they associated?'. Homogeneity: several groups sampled separately, same margins arithmetic, asking 'do the groups share one distribution?'. Goodness of fit: one variable, expected counts from proportions stated in advance — equal shares or a theory's ratio — asking 'do the counts fit the claim?', with df = categories − 1 instead of (rows − 1) × (columns − 1).
What are the assumptions of the chi-square test?
Independent observations, each contributing to exactly one cell; data as genuine counts rather than percentages, rates or means; categories that are mutually exclusive and cover every observation; and expected counts large enough for the approximation — Cochran's rule, every expected count at least 1 and at least 80% of cells at 5 or more. Nothing is assumed about the shape of the underlying populations, which is why the test is called non-parametric — the fragile assumption is the approximation itself.
Can I use percentages?
No. The statistic measures how much evidence the counts carry, and percentages erase exactly that: an 80/20 split is 8 against 2 in a sample of 10 and 800 against 200 in a sample of 1,000, with completely different χ² values. Convert percentages back to counts first — percentage × group size, rounded to whole numbers — and if the group sizes were never reported, the test cannot be run from the percentages alone.
Why does my p-value show as a power of ten?
Because it is smaller than 0.00005, where four decimal places would round it to 0.0000 — and a p-value is never exactly zero. The calculator switches to scientific notation, such as 3.2 × 10⁻⁵, which reads as 0.000032. In APA style you would simply report p < .001. A power-of-ten p-value means the counts depart from the null far beyond ordinary chance variation — provided the validity verdict passed; on a table that fails Cochran's rule, even a tiny approximate p-value should be confirmed with the exact test.