Expected Counts Under Independence
A contingency table records counts for two categorical variables. In an independence test, the observed cell counts are compared with the counts expected if the variables were independent. The expected counts depend on the table’s row and column totals: they are not generally equal across cells, and they need not be whole numbers.
This formula applies to an ordinary, unrestricted table when the null model is independence and the margins are estimated from the observed table. It follows because the estimated probability of row \(i\) is \(n_{i+}/n\), and the estimated probability of column \(j\) is \(n_{+j}/n\). Under independence, the joint probability is the product of those probabilities. Multiplying that product by \(n\) gives the expected count.
Worked Example: Expected Counts in an Unrestricted Table
A hypothetical study records 80 policy inquiries by inquiry type and response channel. The observed counts are:
| Inquiry type | Online | Telephone | Row total |
|---|---|---|---|
| Billing | 18 | 12 | 30 |
| Coverage | 12 | 18 | 30 |
| Claims | 10 | 10 | 20 |
| Column total | 40 | 40 | 80 |
Find the expected counts under independence and the degrees of freedom.
Method. First calculate each expected count from its row total, column total, and the grand total. Then calculate the unrestricted degrees of freedom.
For Billing and Online, \(E_{11}=(30)(40)/80=15\). For Billing and Telephone, \(E_{12}=(30)(40)/80=15\).
For Coverage, each expected count is \((30)(40)/80=15\). For Claims, each is \((20)(40)/80=10\).
Thus the expected table is:
| Inquiry type | Online | Telephone | Row total |
|---|---|---|---|
| Billing | 15 | 15 | 30 |
| Coverage | 15 | 15 | 30 |
| Claims | 10 | 10 | 20 |
| Column total | 40 | 40 | 80 |
The table has \(r=3\) rows and \(c=2\) columns, so its degrees of freedom are \((3-1)(2-1)=2\). The expected row totals and column totals match the observed margins, as required. The common mistake is to divide the grand total evenly among six cells; that would ignore the margins and does not represent the independence model.
Why the Unrestricted Degrees of Freedom Have This Form
The degrees of freedom count how many independent pieces of information remain in a test statistic after the model has been fitted. For an unrestricted table, each observed cell count cannot vary freely once its row and column totals are fixed. Equivalently, the independence model has fewer free probabilities than a model assigning a separate probability to every cell.
Here is a parameter-count justification. A general joint distribution over \(rc\) cells has \(rc-1\) free probabilities, because the probabilities sum to one. Under independence, the row probabilities have \(r-1\) free values and the column probabilities have \(c-1\) free values. Their products determine all joint cell probabilities, so the independence model has \(r+c-2\) free parameters. The difference is $$ (rc-1)-(r+c-2)=rc-r-c+1=(r-1)(c-1). $$ The same count comes from the margins: after fixing all row and column totals, one margin is redundant because both sets sum to \(n\). Thus \(r+c-1\) margins constrain the \(rc\) cells, leaving \(rc-r-c+1\) independent cell variations.
An unrestricted table has \(rc\) cell counts.
The row and column margins impose \(r+c-1\) independent constraints; one total is shared by both sets.
The remaining dimension is \(rc-(r+c-1)=(r-1)(c-1)\).
For example, a 2-by-2 table has one degree of freedom, not four: its row and column margins determine all but one cell. Once that cell is specified, the other three follow from the margins. In larger tables the same principle applies, even though there are more possible patterns of variation.
Structural Zeros and Restricted Tables
A structural zero is a cell that cannot occur because of the way the categories or population are defined. It differs from a sampling zero, which is a possible cell that happened to receive no observations in a particular sample. A structural zero is excluded from the model; it is not a cell with expected count zero that should be inserted into the ordinary Pearson sum.
With structural zeros, the ordinary formula \(n_{i+}n_{+j}/n\) may assign a positive expected count to an impossible cell. Instead, a common restricted-table model is quasi-independence: among the allowed cells, fitted expected counts have the multiplicative form \(m_{ij}=a_i b_j\), with row and column factors chosen to match the observed margins. The fitted values must be zero in forbidden cells, and the allowed-cell factors generally must be fitted together. The ordinary row-total times column-total formula is not generally valid after restrictions are imposed.
The graph count is useful because restrictions can change both the number of cells and the number of independent row-and-column parameters. If the allowed-cell pattern splits into disconnected pieces, each component contributes one redundancy between its row and column factors. If the resulting degrees of freedom are zero, the fitted model is saturated for the allowed cells: it leaves no independent cell variation for a goodness-of-fit test.
Worked Example: Fitting Expected Counts With a Structural Zero
A hypothetical service records request type and handling team. A particular type of request cannot be handled by Team C, so the cell in row 3, column 3 is structurally impossible. The observed counts are:
| Request type | Team A | Team B | Team C | Row total |
|---|---|---|---|---|
| Type 1 | 1 | 2 | 2 | 5 |
| Type 2 | 6 | 0 | 4 | 10 |
| Type 3 | 1 | 2 | — | 3 |
| Column total | 8 | 4 | 6 | 18 |
Find the quasi-independence expected counts and degrees of freedom.
Method. Exclude the forbidden cell, then fit multiplicative expected counts on the allowed cells. The allowed expected counts \((2,1,2;\;4,2,4;\;2,1)\) have the form \(a_i b_j\): take row factors \((1,2,1)\) and column factors \((2,1,2)\). The fitted table is therefore:
| Request type | Team A | Team B | Team C | Row total |
|---|---|---|---|---|
| Type 1 | 2 | 1 | 2 | 5 |
| Type 2 | 4 | 2 | 4 | 10 |
| Type 3 | 2 | 1 | — | 3 |
| Column total | 8 | 4 | 6 | 18 |
Each fitted row total and column total equals its observed counterpart. Because the fitted counts have the required multiplicative form and match the observed margins, they satisfy the quasi-independence fitting equations.
There are \(m=8\) allowed cells, \(r=3\) active rows, and \(c=3\) active columns. Every row and column is connected through the allowed-cell pattern, so \(K=1\). Hence the degrees of freedom are \(8-3-3+1=3\). The common mistake is to treat the forbidden cell as an ordinary zero and apply the unrestricted expected-count formula. That formula would assign it a positive count, contradicting the model.
Worked Example: A Restriction That Leaves No Test Degrees of Freedom
In a hypothetical 2-by-2 classification, only the off-diagonal combinations are possible. The observed counts are 7 in row 1, column 2, and 5 in row 2, column 1; the diagonal cells are structural zeros. Determine the quasi-independence fitted counts and degrees of freedom.
Method. There are only two allowed cells. Their counts already determine the row totals \((7,5)\) and column totals \((5,7)\), so the fitted counts must be 7 and 5 in those cells. Each allowed cell is its own connected component in the bipartite graph: one component joins row 1 to column 2, and the other joins row 2 to column 1. Thus \(m=2\), \(r=2\), \(c=2\), and \(K=2\).
The degrees of freedom are \(2-2-2+2=0\). The model fits every allowed count exactly, so there is no remaining variation with which to test the model. Using the ordinary 2-by-2 formula would give one degree of freedom, but that calculation incorrectly assumes all four cells are possible.
Practical Interpretation and Exam Traps
Expected counts and degrees of freedom answer different questions. Expected counts describe the fitted null model cell by cell. Degrees of freedom describe how many independent departures from that fitted model remain. A table can have many allowed cells but few degrees of freedom if its margins and restrictions tightly determine the counts.
- Do not confuse a sampling zero with a structural zero. A sampling zero is still an allowed cell and remains part of the fitted model. A structural zero is excluded.
- Do not use \((r-1)(c-1)\) automatically. It applies to a complete, unrestricted table, not a table with structural restrictions.
- Do not use the ordinary expected-count formula for a restricted table without checking it. The fitted counts must respect impossible cells and the model used for the allowed cells.
- Do not count an inactive category. A row or column with no allowed cells cannot contribute a fitted parameter or an allowed-cell edge.
In the ordinary setting, calculate each expected count using the observed margins and calculate degrees of freedom from the table dimensions. When structural restrictions are present, first identify the allowed cells and the fitting model; then count the allowed-cell parameters rather than treating the table as complete. These calculations are aligned with the SOA VEE Mathematical Statistics syllabus.
Check Your Understanding
For each problem, identify the applicable table structure before calculating.
- A 2-by-3 unrestricted table has row totals 30 and 50, and column totals 30, 20, and 30. Find the expected counts in the first row and the degrees of freedom. (Answer: 11.25, 7.50, 11.25; 2 degrees of freedom)
- How many degrees of freedom does an unrestricted 4-by-3 independence test have? (Answer: 6)
- A 2-by-2 table has one structural zero and the other three cells are allowed, with all rows and columns active and connected. Find the quasi-independence degrees of freedom. (Answer: 0)
- A 3-by-3 table has one structural zero and all other cells allowed. The allowed-cell graph is connected. Find the quasi-independence degrees of freedom. (Answer: 3)
- A 2-by-3 table has cell (2,3) structurally impossible, with all rows and columns active and the allowed-cell graph connected. Find the degrees of freedom. (Answer: 1)