# What is the definition of expected counts in chi square tests?

Just wondering whether anyone could define expected counts in regards to a chi square test.

• It depends on the chi square test you're asking about (which in turn depends on the hypothesis and assumptions); the most common ones are the tests of goodness of fit and of independence, but there are others. It will be the expected count under the particular null hypothesis being considered. – Glen_b May 1 '15 at 15:07
• One of (not very often) mentioned definition is that the expected counts are the values of the weighted average profile. "Profile" is a column one or a row one. – ttnphns May 1 '15 at 16:12

Expected counts are the projected frequencies in each cell if the null hypothesis is true (aka, no association between the variables.)

Given the follow 2x2 table of outcome (O) and exposure (E) as an example, a, b, c, and d are all observed counts:

The expected count for each cell would be the product of the corresponding row and column totals divided by the sample size. For example, the expected count for O+E+ would be:

$$\frac{(a+b) \times (a+c)}{a+b+c+d}$$

(see red arrows for the meaning of "corresponding")

Then the expected counts will be contrast with the observed counts, cell by cell. The more the difference, the higher the resultant statistics, which is the $\chi^2$.

Suppose, you have observed data arranged. The total data = n. But, you want to test whether actual outcomes follows any distribution(standard or got-from-expert).

So, you can get:
$$\text{Expected outcome}=n\times Pr(\text{that outcome})$$ or for expected values in contingency table:
$$\text{Expected outcome}=\frac{(\text{sum of data in that row})\times(\text{sum of data in that column})}{\text{total data}}$$

The other answers don't really explain where the formula for the expected counts comes from. Here's my attempt.

Consider the following example (data taken from this site). $$\begin{bmatrix} \ & \text{Effect 1} & \text{Effect 2} & \text{Totals}\\ \text{group A} & 300 & 460 & 760\\ \text{group B} & 249 & 95 & 344\\ \text{Totals} & 549 & 555 & 1104\\ \end{bmatrix}$$

In a Chi-squared test, we want to compare the observed counts vs the expected counts under the assumption of independence. But how do we determine the expected counts?

Firstly, observe that $$\frac{760}{1104}$$ of the individuals are in group A. Likewise, observe that $$\frac{549}{1104}$$ have effect 1. If we assume that these two events are independent, then the probability of these two events is the product of the probabilities. I.e. if we call these events $$A,B$$, then assuming they are independent then $$P(A\cap B)=P(A)\cdot P(B)$$. Thus in our example, if the independence assumption holds, we have that the probability of being in group A and having effect 1 is: $$\frac{760}{1104} \cdot \frac{549}{1104} = 34.23\%$$

Since there are 1104 people total, and 34.23% of them are expected to be in group A and have effect 1, we expect $$1104\cdot.3423 = 377.93$$ people to be in the relevant cell of the table (as opposed to the 300 we actually observed).

Combining these two steps and simplifying with algebra the formula becomes:

$$\underbrace{\frac{760}{1104} \cdot \frac{549}{1104}}_{=34.23\%} \cdot 1104 = \frac{760\cdot 549}{1104} = 377.93$$

Thus, we've shown $$\text{Expected count}=\frac{(\text{sum of data in that row})\times(\text{sum of data in that column})}{\text{total data}}$$ as claimed. Try to calculate the expected values for the other cells in the table. The answers are shown here.