Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Could I say that if the $\chi^2$ value of a dataset is $0$, then the frequencies of the values of the cells in the contingency table are all the same? I have noticed that if I change the frequency of any of these values to be more than the other, that $\chi^2$ stops being $0$.



Any help appreciated

share|cite|improve this question
up vote 3 down vote accepted

It depends on which chi-square test you're talking about. There are many. One frequently used chi-square test with contingency tables is a test of independence of rows and columns. Consider this table: $$ \begin{array}{rr|r} \hline 2 & 12 & 14 \\ 3 & 18 & 21 \\ \hline 5 & 30 & 35 \end{array} $$ The numbers in the rightmost column to the right of the vertical line are the sums of the numbers in the rows to the left of the line; the numbers in the bottom row below the horizontal line are the sums of the numbers in the columns above the line; the 35 in the lower right is the sum of the two numbers above it, or equivalently, of the two numbers to its left, or, again equivalently, of the four numbers in the $2\times 2$ table above and to the left of the margins.

Take the number in each cell in the $2\times 2$ table to be the number of individuals in the sample that fall in that cell. The null hypothesis says the probability that an individual is in a particular row is independent of which column that individual is in and vice-versa. The observed numbers are totals in the sample rather than in the population, so you generally won't see perfect independence in the sample even if the null hypothesis is true. Since they're based on the sample rather than on the whole population, if we say the probability of being in the first row is $14/35 = 2/5$ (taking the numbers 14 and 21 from the right margin), that is an estimate. Similarly we can estimate the probability of being in the first column as $5/35 = 1/7$. The probability of being in the cell that is the upper left corner of the table, assuming that the null hypothesis of independence is true, is therefore estimated as $(14/35) \times (5/35) = 2/35$. Since the sample size is 35, the expected count in the first cell is therefore $(14/35) \times (5/35) \times 35$ (and the obvious cancelation of 35 with 35 would happen even if all of the numbers had been different). Call this estimated expected value the expected count in the first cell.

In various chi-square tests (not all chi-square tests, but most chi-square tests that involve categorical data), the test statistic can be written as $$ \sum \frac{(\text{observed} - \text{expected})^2}{\text{expected}}. $$

If you work out the chi-square test statistic for the table with the particular numbers I've put there, you'll find it's exactly 0, simply because I chose the numbers to make that happen.

But the four numbers are not equal.

On the other hand, if you're doing the simple chi-square test of the null hypothesis that says an ordinary six-sided die is "fair", then the "expected" counts will each be $1/6$ of the sample size---thus all equal to each other---and the chi-square test statistic then won't be 0 unless all six counts in the sample are equal.

Bottom line answer to your question: No.

share|cite|improve this answer

A shorter answer than Michael Hardy's (which is good, by the way): the test statistics you're dealing with are probably of the form $$ \sum_i {(O_i - E_i)^2 \over E_i}. $$ where $O_i$ are observed counts and $E_i$ are expected counts. This will be zero, not if all the $O_i$ are the same, but if all the $O_i$ are equal to the corresponding $E_i$. That is, chi-squared is zero in these cases if the observed counts are equal to the corresponding expected counts.

Now, since the numerator of each term in the sum is nonnegative, then every term in the sum is nonnegative. And if the observed counts are not all equal to the corresponding expected counts, then at least one term is actually positive, so chi-squared is greater than zero.

So chi-squared equals zero if, and only if, the observed counts equal the expected counts. (This happens rarely because there are inevitable fluctuations; this is why we require chi-squared to be some reasonably large number in order to reject the hypothesis that the observed and expected distributions are the same.)

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.