Why Calculate Expected Cell Counts?
A two-way table organizes counts for two categorical variables. Its observed counts show what happened in the sample. To assess whether the variables are associated, we also need a reference: what counts would fit the assumption that the variables are independent? Those reference values are the expected cell counts.
An expected count is not a second set of observed data, nor is it a guarantee about what any future sample will contain. It is the count predicted for a cell by a specified model—in this tutorial, the model of independence—while matching the table’s observed row and column totals. The calculation is important because it gives a cell-by-cell comparison between observed data and the independence model.
The formula uses two marginal totals and the grand total. It does not use the observed count in the individual cell. A cell’s expected count is large when its row contains many observations and its column is common overall; it is small when either its row or its column is relatively small.
Where the Formula Comes From
Under independence, the probability of a row category and a column category occurring together is the product of their separate probabilities. If the probability of row \(i\) is \(p_{i+}\) and the probability of column \(j\) is \(p_{+j}\), then the model assigns probability \(p_{i+}p_{+j}\) to their joint cell. Multiplying a cell probability by the total number of observations gives the corresponding expected count.
In practice, the marginal probabilities in this model are estimated from the table’s margins: \(p_{i+}\) is estimated by \(n_{i+}/n\), and \(p_{+j}\) by \(n_{+j}/n\). Substituting those proportions into the model gives the expected count.
There is also a direct justification when both margins are treated as fixed. Under independence, once the column total \(n_{+j}\) is set, its observations are distributed across the \(n\) row positions without preference for any one row. For row \(i\), each of its \(n_{i+}\) positions has probability \(n_{+j}/n\) of belonging to column \(j\). The cell count is the sum of indicators for those positions, so linearity of expectation gives the formula:
Here \(I_k\) equals 1 if the \(k\)th position in row \(i\) is in column \(j\), and 0 otherwise. The derivation shows why the calculation is based on the margins: it distributes the column total across row positions in proportion to the row totals.
Worked Calculation in a Two-Way Table
The most reliable approach is to calculate each row-column combination, using the same grand total throughout, and then check that the expected counts reproduce the margins. The following example shows the calculation for every cell.
Worked Example: Expected Counts for Two Student Groups
In a hypothetical survey of 100 students, students are classified by year group and usual travel method. The observed counts are shown below. Calculate the expected count in each cell under independence.
| Year group | Bus | Bicycle | Walk | Row total |
|---|---|---|---|---|
| First year | 10 | 12 | 18 | 40 |
| Upper year | 20 | 8 | 32 | 60 |
| Column total | 30 | 20 | 50 | 100 |
For the first-year, bus cell, the row total is 40, the bus column total is 30, and the grand total is 100:
The other five cells use their own row and column totals:
Thus the expected counts are 12, 8, and 20 in the first-year row, and 18, 12, and 30 in the upper-year row. These are the counts the fitted independence model assigns to the cells; they are not replacements for the observed counts.
Check the margins. The first-year expected counts sum to \(12+8+20=40\), and the upper-year counts sum to \(18+12+30=60\). The expected bus counts sum to \(12+18=30\); bicycle counts to \(8+12=20\); and walk counts to \(20+30=50\). Each matches its observed margin, as the formula requires.
A Multirow, Multicolumn Calculation
In a larger table, there is no new rule for each additional row or column. Apply \(E_{ij}=n_{i+}n_{+j}/n\) to every cell. The totals provide a useful way to organize the arithmetic and detect mistakes.
Worked Example: Expected Counts in a Three-by-Four Table
A hypothetical survey records which of four services respondents selected, grouped by region. The observed table and margins are:
| Region | Service X | Service Y | Service Z | Service W | Row total |
|---|---|---|---|---|---|
| A | 8 | 12 | 15 | 15 | 50 |
| B | 14 | 21 | 18 | 17 | 70 |
| C | 18 | 27 | 17 | 18 | 80 |
| Column total | 40 | 60 | 50 | 50 | 200 |
For Region A and Service X, the expected count is \(50(40)/200=10\). For Region A and Service Y, it is \(50(60)/200=15\). Continuing across that row gives \(50(50)/200=12.5\) for each of Services Z and W.
For Region B, the calculations are \(70(40)/200=14\), \(70(60)/200=21\), and \(70(50)/200=17.5\) for each of Services Z and W. For Region C, they are \(80(40)/200=16\), \(80(60)/200=24\), and \(80(50)/200=20\) for each of Services Z and W.
The full expected-count table is therefore:
| Region | Service X | Service Y | Service Z | Service W | Row total |
|---|---|---|---|---|---|
| A | 10 | 15 | 12.5 | 12.5 | 50 |
| B | 14 | 21 | 17.5 | 17.5 | 70 |
| C | 16 | 24 | 20 | 20 | 80 |
| Column total | 40 | 60 | 50 | 50 | 200 |
For example, Region C and Service Y has expected count \(80(60)/200=24\). The expected row totals are \(10+15+12.5+12.5=50\), \(14+21+17.5+17.5=70\), and \(16+24+20+20=80\). The expected column totals are 40, 60, 50, and 50. All margins match.
Expected Counts in a Homogeneity Table
The same calculation applies when the rows represent separate groups and the question is whether the groups have the same distribution across the column categories. This is the setting of a test of homogeneity. The expected count in a cell still comes from its row total, its pooled column total, and the grand total.
Worked Example: Comparing Three Clinics
Suppose three hypothetical clinics each record a patient’s preference among three appointment formats. The clinics have different sample sizes, and their observed counts are:
| Clinic | Format A | Format B | Format C | Row total |
|---|---|---|---|---|
| 1 | 25 | 12 | 8 | 45 |
| 2 | 14 | 10 | 6 | 30 |
| 3 | 11 | 8 | 6 | 25 |
| Column total | 50 | 30 | 20 | 100 |
For Clinic 1 and Format A, the expected count is \(45(50)/100=22.5\). The full set of calculations gives:
For instance, Clinic 2’s expected count for Format B is \(30(30)/100=9\), while Clinic 3’s is \(25(30)/100=7.5\). The row totals of the expected counts are 45, 30, and 25; the column totals are 50, 30, and 20. Different clinic sample sizes change the row totals, but do not change the formula.
Interpreting and Checking the Results
Expected counts can be fractional because they are model-based averages, not actual people or events counted in a sample. An expected count of 12.5 is perfectly valid. Rounding it to 13 before using it in a later calculation changes the model-based value and can introduce avoidable error. Keep the unrounded values during calculations, and report sensible precision when needed.
A few checks make expected-count tables easier to trust:
- Each expected count uses the row total for its row and the column total for its column.
- The grand total \(n\) is the same for every cell.
- Expected counts in each row sum to that row’s total, and expected counts in each column sum to that column’s total.
- All expected counts together sum to the grand total.
The last check follows from the row sums: adding all expected row totals gives the sum of the row totals, which is \(n\). These checks can reveal a wrong margin, a mismatched cell, or an arithmetic error. They do not establish that the independence model is appropriate; they only confirm the calculation.
Common Mistake: Reusing the Observed Cell Count
A frequent error is to treat the expected count as a modification of the observed count—for example, to use the observed cell count in the numerator or to copy it into the expected table. That is not the calculation. Under independence, each expected count is determined by the row and column margins, not by the count observed in that particular cell.
In the student example, the observed count for first-year students who take the bus is 10, but the expected count is \(40(30)/100=12\). The value 10 does not enter that formula. In another table, a cell could have observed count zero and still have a positive expected count if both its row and column totals are positive. An expected count describes what the model predicts on average for the cell; it need not equal the observed count.
Check Your Understanding
Use the expected-count formula and the table margins to answer these questions.
- A table has grand total 120. A cell lies in a row total of 30 and a column total of 48. What is its expected count under independence?
- In a table with grand total 200, a row total of 70 and a column total of 50 intersect. Calculate the expected count and state whether it should be rounded before further calculations.
- Why does the expected-count formula use a row total and a column total rather than the observed count in the cell?
- If calculated expected counts in one row do not sum to that row’s total, name two possible sources of error.
- In a homogeneity table, why can groups with different sample sizes have different expected counts in the same column category?