Tutorials › Introduction to Statistics › Standardized Residuals for Cell-Level Diagnosis

Chi-Square Tests of Independence and Homogeneity · Tutorial 834 of 996

Standardized Residuals for Cell-Level Diagnosis

Calculate adjusted standardized residuals for a two-way table and use their approximate standard-normal scale to identify cells with larger-than-expected or smaller-than-expected counts.

Intermediate 10 min read

What You'll Learn

  • Define the adjusted standardized residual for a cell in a two-way table.
  • Calculate expected counts and adjusted residuals from observed cell counts and margins.
  • Explain how the row and column proportions adjust the residual’s standard error.
  • Interpret a residual’s sign and magnitude in the context of the table.
  • Recognize why residuals are approximate diagnostics, not independent tests for every cell.

Why Standardize Cell Residuals?

A Pearson residual shows how far a cell’s observed count is from its expected count, measured in units of the square root of that expected count. But cells in a two-way table share row and column totals. Those fixed or estimated margins constrain how much a cell count can vary. An adjusted standardized residual takes this into account, giving a more suitable approximate standard-normal scale for diagnosing individual cells.

The aim is to see which cells depart most from the independence model: which have notably more observations than expected, and which have notably fewer. This is a cell-level diagnostic. It complements the overall Pearson chi-square test, but it does not replace that test or remove the need to consider the table’s sampling conditions.

Definition: For cell \(i,j\), let \(O_{ij}\) be its observed count, \(E_{ij}\) its expected count under independence, \(R_i\) the total for row \(i\), \(C_j\) the total for column \(j\), and \(N\) the table total. The adjusted standardized residual is $$ ASR_{ij}=\frac{O_{ij}-E_{ij}}{\sqrt{E_{ij}\left(1-\frac{R_i}{N}\right)\left(1-\frac{C_j}{N}\right)}}. $$

The expected count under independence is \(E_{ij}=R_iC_j/N\). Thus the two proportions in the denominator are the share of all observations in the cell’s row and the share in its column. The numerator is the cell’s observed-minus-expected difference. The denominator estimates the standard deviation of that difference after accounting for both margins.

What the Adjusted Residual Tells You

A positive adjusted residual means \(O_{ij}>E_{ij}\): that cell contains more observations than the independence model predicts. A negative value means fewer. The absolute value describes how many adjusted standard-error units the observed count lies from its expected count. For example, an adjusted residual of \(2.4\) means the observed count is 2.4 estimated standard errors above its expected count.

Under the null model of independence, adjusted standardized residuals are approximately standard normal when the table is sufficiently large and the usual chi-square conditions are met. This makes values near zero unsurprising; larger absolute values are more unusual under independence. The approximation is not exact, and the residuals in a table are not independent of one another. Therefore, a large residual is a diagnostic signal, not by itself a definitive cell-specific test.

Worked Example: A Two-by-Two Table

Suppose a hypothetical survey records whether 200 people in two groups prefer a new menu item. The counts are shown below.

GroupPreferDo not preferTotal
A5050100
B3070100
Total80120200

Assume the observations are independent and the counts meet the conditions for chi-square inference. Under independence, the expected count for Group A and “Prefer” is

$$ E_{11}=\frac{R_1C_1}{N}=\frac{100(80)}{200}=40. $$

The row proportion is \(100/200=0.50\), and the column proportion is \(80/200=0.40\). Therefore,

$$ ASR_{11}=\frac{50-40}{\sqrt{40(1-0.50)(1-0.40)}} =\frac{10}{\sqrt{12}} \approx 2.887. $$

The observed count in this cell is about 2.9 adjusted standard errors above its expected count. In context, the survey has more Group A respondents who prefer the item than the independence model predicts. This residual alone does not establish that the groups differ; it identifies a cell contributing a notable departure that merits interpretation alongside the overall analysis.

For comparison, the expected count in the “Group A, Do not prefer” cell is \(100(120)/200=60\). Its adjusted residual is

$$ \frac{50-60}{\sqrt{60(1-0.50)(1-0.60)}} =\frac{-10}{\sqrt{12}} \approx -2.887. $$

The negative sign indicates fewer Group A respondents in that cell than expected. The two residuals are related: a row total constrains the counts in that row, so one should not treat cell residuals as independent pieces of evidence.

Why the Denominator Includes Both Margins

The Pearson residual is \((O_{ij}-E_{ij})/\sqrt{E_{ij}}\). The adjusted residual changes its scale because the variation in a cell count is reduced when its row and column totals are taken into account. A short variance calculation explains the adjustment.

Under independence, if the row and column margins are fixed, the count \(O_{ij}\) has a hypergeometric distribution: among \(N\) observations, \(R_i\) belong to row \(i\), and \(C_j\) positions belong to column \(j\). Its mean is \(R_iC_j/N=E_{ij}\). The variance of a hypergeometric count is the number of draws times the success proportion, the failure proportion, and the finite-population correction. Here that gives

$$ \operatorname{Var}(O_{ij}) =C_j\left(\frac{R_i}{N}\right)\left(1-\frac{R_i}{N}\right) \left(\frac{N-C_j}{N-1}\right) =E_{ij}\left(1-\frac{R_i}{N}\right)\left(1-\frac{C_j}{N}\right)\frac{N}{N-1}. $$

The factor \(N/(N-1)\) is a finite-sample correction that approaches 1 as \(N\) grows. Dropping this small factor gives the variance estimate in the adjusted residual’s denominator squared. Dividing the observed-minus-expected difference by that estimated standard deviation produces the usual adjusted standardized residual. For sufficiently large counts, the standardized difference is approximately standard normal. When margins arise from sampling rather than being fixed by design, the same formula is used as an approximate large-sample diagnostic under the independence model.

Worked Example: Comparing Cells in a Three-by-Two Table

In a hypothetical survey, 240 people from three groups choose between two options. Each row total is 80, and each column total is 120. The observed counts are:

GroupOption 1Option 2Total
A503080
B404080
C305080
Total120120240

For every cell, the independence-model expected count is \(80(120)/240=40\). The row proportion is \(80/240=1/3\), and each column proportion is \(120/240=1/2\). For Group A choosing Option 1,

$$ ASR_{11}=\frac{50-40}{\sqrt{40(1-\frac{1}{3})(1-\frac{1}{2})}} =\frac{10}{\sqrt{13.333}} \approx 2.739. $$

The count of 50 is above its expected value of 40, with a residual about 2.7 adjusted standard errors above zero. For Group A choosing Option 2, the difference is \(30-40=-10\), so the adjusted residual is \(-2.739\). Group B has observed counts equal to both expected counts, so its two adjusted residuals are zero. Group C has residuals \(-2.739\) for Option 1 and \(2.739\) for Option 2.

This calculation illustrates that equal observed-minus-expected differences need not always yield equal adjusted residuals in tables with unequal margins. Here the margins are balanced, so the denominators match across cells. In a table with different row or column proportions, the adjustment can change the relative magnitudes.

Calculating Residuals Systematically

For a full table, work cell by cell. First calculate the expected count from its row and column totals. Then calculate the adjusted denominator using those same margins, and divide the observed-minus-expected difference by it. Retain the sign: it carries the direction of the departure. A compact table of results can make the cells with the largest absolute residuals easy to identify.

Worked Example: Unequal Margins

Consider a hypothetical table of 300 observations, with row totals 120, 100, and 80, and column totals 90, 120, and 90. The observed counts are shown below.

GroupCategory 1Category 2Category 3Total
A504525120
B254035100
C15353080
Total9012090300

For Group A and Category 1, the expected count is \(120(90)/300=36\). The row proportion is \(0.40\), and the column proportion is \(0.30\). Thus,

$$ ASR_{11}=\frac{50-36}{\sqrt{36(1-0.40)(1-0.30)}} =\frac{14}{\sqrt{15.12}} \approx 3.600. $$

The same procedure gives the following residuals. For instance, Group A and Category 3 has expected count \(120(90)/300=36\), giving \((25-36)/\sqrt{36(0.60)(0.70)}\approx -2.829\). The table reports residuals rounded to three decimal places.

GroupCategory 1Category 2Category 3
A3.600-0.722-2.829
B-1.3360.0001.336
C-2.5640.8001.709

For Group C and Category 1, for example, the expected count is \(80(90)/300=24\). The denominator is \(\sqrt{24(1-80/300)(1-90/300)}=\sqrt{12.32}\), and the residual is \((15-24)/\sqrt{12.32}\approx-2.564\). Its negative sign indicates a lower count than expected. Group A and Category 1 has the largest absolute residual in this table, so it is the cell with the strongest standardized departure from its expected count in this diagnostic.

Using the Approximate Normal Scale Carefully

Because the adjusted residual is approximately standard normal under independence, it can be compared with familiar standard-normal reference values. A value around 0 is close to expectation; a value near 2 or \(-2\) is more unusual under the model; and a larger absolute value is a stronger signal of departure. These comparisons are approximate and should be interpreted with the study design and cell counts in mind.

In particular, scanning many cells makes it more likely that at least one residual will be large by chance. Cell residuals are also dependent because the margins constrain the table. Therefore, do not read each residual as a separate, unadjusted hypothesis test or conclude that a cell is definitively significant solely from its magnitude. Use residuals to diagnose where the overall discrepancy may be concentrated, and report the observed and expected counts with the direction of the difference.

Adjusted residuals also differ from Pearson cell contributions. A Pearson cell contribution is \((O_{ij}-E_{ij})^2/E_{ij}\), a nonnegative part of the overall Pearson chi-square statistic. The adjusted residual is signed and uses an adjusted denominator. Its square is therefore not generally the Pearson contribution, and adjusted residuals should not be squared and summed to reconstruct the Pearson chi-square statistic.

Common Mistakes

  • Using only the expected count in the denominator. That gives a Pearson residual, not an adjusted standardized residual. Include both margin factors, \(1-R_i/N\) and \(1-C_j/N\).
  • Discarding the sign. The absolute value describes magnitude, but the sign distinguishes more observations than expected from fewer.
  • Calling a large residual proof of association in that cell. The normal scale is approximate, and inspecting many cells raises the chance of seeing a large value. Treat it as a diagnostic, not a stand-alone conclusion.
  • Assuming adjusted residuals sum to the Pearson chi-square statistic. The overall statistic is the sum of Pearson cell contributions; adjusted residuals use a different denominator.
Key takeaway: An adjusted standardized residual is the observed-minus-expected cell count divided by an estimated standard deviation that accounts for both margins. Its sign gives the direction of the departure, and its approximate standard-normal scale helps locate cells that merit attention.

Check Your Understanding

Try these questions without looking back.

  1. In a two-way table, a cell has observed count 28 and expected count 20. What does the sign of its adjusted standardized residual tell you?
  2. Which two margin proportions appear in the adjusted residual’s denominator?
  3. A cell has adjusted standardized residual \(-2.5\). Interpret its sign and magnitude in context, without claiming that the null hypothesis is false.
  4. Why is an adjusted residual not generally interchangeable with a Pearson cell contribution?
  5. Why should a large residual found while scanning many cells be treated cautiously?