Loading
Quantifying the counts we would expect if two categorical variables were truly independent.
Understanding the relationship between two categorical variables has been a central challenge in statistical analysis since the nineteenth century. When a researcher asks whether smoking status is associated with lung disease, or whether political affiliation differs across age groups, the raw counts in a two-way table (also called a contingency table) provide the starting point. However, observed counts alone cannot tell us whether a pattern is statistically meaningful or merely the product of random variation. To answer that question, we need a benchmark — a set of counts that represents what we would see if the two variables had no association at all. These benchmarks are called expected counts, and they form the theoretical backbone of every chi-square test for independence and homogeneity.
The central question expected counts address is deceptively simple: If two categorical variables were completely independent, how many observations would fall into each cell of a two-way table? Answering this question precisely is what allows us to measure the discrepancy between what we observe and what independence predicts, ultimately powering the chi-square statistic.
Before computing expected counts, it is essential to internalize several foundational ideas that connect probability theory to the structure of contingency tables. These principles ensure you understand not just how to calculate expected counts but why the formula works.
The following diagram illustrates a complete two-way table for a study examining the relationship between exercise frequency (Low, Moderate, High) and health outcome (Healthy, Unhealthy). Observed counts are shown in each cell alongside their row and column marginal totals. The diagram highlights how each cell's expected count derives from its corresponding row total and column total divided by the grand total.
In the diagram above, notice that the observed count for the Healthy-Low cell is 30, but the expected count under independence is 48. This discrepancy is precisely the kind of deviation the chi-square test measures. Each cell's expected count preserves the marginal distributions: the expected values in the Healthy row still sum to 150, and those in the Low column still sum to 80, ensuring overall consistency with the data's structure.
The expected count formula is a direct consequence of the multiplication rule for independent events. If the row variable and column variable are independent, then the probability that a randomly selected observation falls in row i and column j equals the product of the marginal probabilities. Multiplying that joint probability by the grand total gives the expected count.
To see why this formula works, consider that P(Row i) is estimated by Ri / n and P(Col j) is estimated by Cj / n. Under independence, the expected proportion in cell (i, j) is (Ri / n) × (Cj / n). Multiplying by n yields (Ri × Cj) / n, which is the standard formula. This derivation makes clear that expected counts allocate the grand total across cells in exact proportion to the marginal distributions.
Returning to our exercise-and-health example, let us compute the expected count for every cell and display the full table side by side with the observed counts. This comparison provides immediate visual insight into which cells contribute most to the chi-square statistic. When computing expected counts, always use unrounded intermediate values; rounding prematurely introduces error that compounds in the chi-square calculation.
A university admissions office wants to investigate whether admission status (Admitted, Denied) is associated with the applicant's intended major (Engineering, Business, Liberal Arts). A random sample of 400 applicants yields the following observed counts.
| Engineering | Business | Liberal Arts | Row Total | |
|---|---|---|---|---|
| Admitted | 80 | 60 | 100 | 240 |
| Denied | 40 | 60 | 60 | 160 |
| Col Total | 120 | 120 | 160 | 400 |
| Common Pitfall | Why It's Wrong | Correct Approach |
|---|---|---|
| Using observed counts in the denominator of the χ² formula | The formula divides by expected counts, not observed counts. Using observed counts changes the distribution of the test statistic. | Always divide (O − E)² by E, the expected count. |
| Rounding expected counts to whole numbers | Expected counts are theoretical values and need not be integers. Premature rounding introduces unnecessary error. | Keep at least two decimal places throughout all calculations. |
| Ignoring the validity condition | If any expected count is below 5, the χ² distribution is a poor approximation, and the p-value may be unreliable. | State that all expected counts are ≥ 5 as part of your conditions check on the AP exam. |
| Confusing the test for independence with the test for homogeneity | Both use the same χ² formula and expected count calculation, but the sampling designs differ (one sample vs. separate samples from each population). | Identify the study design first. Hypotheses and calculations remain the same; interpretation and context differ. |
| Computing expected counts using proportions from the sample instead of the formula | While conceptually equivalent, manually multiplying proportions increases the risk of rounding error compared to the direct formula. | Use E = (Row Total × Column Total) / Grand Total directly. |
Expected counts in two-way tables form the gateway to a broader family of chi-square procedures and advanced categorical analysis. Understanding expected counts thoroughly prepares you not only for the AP exam but also for more sophisticated methods you may encounter in college-level statistics or data science coursework.
| Feature | Expected Counts (AP Level) | Advanced Extensions |
|---|---|---|
| Table size | r × c tables with moderate cell counts | Multi-way tables (3+ variables) analyzed via log-linear models |
| Small expected counts | Combine categories or note violation | Fisher's exact test, simulation-based tests, or exact conditional inference |
| Effect size | Chi-square statistic and p-value | Cramér's V, phi coefficient, standardized residuals for individual cells |
| Model complexity | Test for independence or homogeneity | Logistic regression, generalized linear models for categorical response |
| Interpretation focus | Is there an association? (yes/no) | Which specific cells deviate most? What is the nature and direction of the association? |
One particularly useful extension is the concept of standardized residuals, defined as (O − E) / √E for each cell. While the AP exam focuses on the overall χ² statistic, standardized residuals allow researchers to pinpoint which specific cells contribute most to a significant result. A standardized residual exceeding ±2 suggests that particular cell deviates substantially from what independence predicts — a technique that bridges the gap between the simple hypothesis test and deeper exploratory analysis of categorical data.
Expected counts represent the theoretical cell frequencies in a two-way table under the null hypothesis of independence between two categorical variables. They are computed using the formula E = (Row Total × Column Total) / Grand Total, which distributes the grand total across cells in exact proportion to the marginal distributions. Expected counts need not be integers, should never be rounded for calculations, and must each be at least 5 for the chi-square approximation to be valid.
The chi-square test statistic is computed as χ² = Σ (O − E)² / E, summing over all cells, and is compared to a chi-square distribution with df = (r − 1)(c − 1). On the AP exam, always verify the expected count condition explicitly, present your expected counts clearly, and interpret your results in the context of the problem. Mastering expected counts is essential for both the chi-square test for independence and the chi-square test for homogeneity.
Keep learning with more lessons from the same subject.