COLLEGE STATISTICS • CATEGORICAL DATA ANALYSIS

Expected Counts for Chi-Square — Expected Counts and Conditions for Chi-Square

Learn how to compute expected frequencies and verify the conditions that make chi-square inference valid.

Historical Context & Motivation

Statistical inference about categorical data presents a fundamentally different challenge than inference about continuous measurements. When a researcher records whether subjects fall into categories—political affiliation, blood type, customer preference—the resulting data are counts rather than means, and the familiar z- and t-procedures no longer apply. The need for a dedicated framework to compare observed categorical frequencies against theoretical or hypothesized frequencies motivated one of the most versatile tools in all of statistics: the chi-square test. At the heart of every chi-square test lies the concept of expected counts—the frequencies we would anticipate in each cell if the null hypothesis were true—and the validity of the entire procedure rests on a set of conditions that must be checked before any conclusion is drawn.

1900
Pearson's Chi-Square Statistic
Karl Pearson introduced the chi-square goodness-of-fit test in his landmark paper, providing the first rigorous method for comparing observed categorical frequencies to expected frequencies derived from a theoretical model.
1922
Fisher's Refinement of Degrees of Freedom
Ronald Fisher corrected Pearson's degrees-of-freedom calculation for cases where parameters are estimated from the data, clarifying when and how the chi-square approximation holds.
1934
Cochran's Sample-Size Guidelines
William Cochran published influential guidelines recommending minimum expected counts (often cited as 5 per cell), establishing the practical conditions that statisticians still reference today.
1954
Yates's Continuity Correction
Frank Yates proposed a continuity correction for 2 × 2 tables, addressing the gap between the discrete nature of counts and the continuous chi-square distribution used to approximate p-values.

The central question this lesson addresses is twofold: how do we calculate the expected counts that serve as the benchmark in any chi-square test, and what conditions must be satisfied so that the chi-square distribution provides a reliable approximation to the true sampling distribution of the test statistic? Without a firm grasp of both, even a correctly computed test statistic may lead to erroneous conclusions.

Core Principles & Definitions

Before computing any chi-square statistic, you must understand the conceptual scaffolding on which the test rests. The chi-square family encompasses three common tests—goodness of fit, test of independence, and test of homogeneity—and all three rely on the same underlying logic: compare what you observe in the data to what you would expect under a specific null hypothesis. The magnitude of the discrepancy, measured in a standardized way, determines the test statistic. Below are the foundational ideas that underpin expected count calculations and the conditions for their use.

1

Expected Count

The theoretical frequency of observations in a category or cell if the null hypothesis is exactly true. For goodness of fit, E = n × p₀; for two-way tables, E = (row total × column total) / grand total.
2

Observed Count

The actual number of observations that fall into a given category or cell in the sample data. Denoted O (or sometimes f_obs), these are the raw data you collect.
3

Chi-Square Statistic

A single number summarizing how far the observed counts deviate from expected counts across all cells: χ² = Σ (O − E)² / E. Larger values signal greater departure from the null hypothesis.
4

Degrees of Freedom

The number of independent pieces of information in the table. For goodness of fit, df = k − 1; for a two-way r × c table, df = (r − 1)(c − 1). This determines which chi-square distribution to reference.
5

Conditions for Inference

A set of requirements—randomness, independence, and adequate expected counts—that must be satisfied for the chi-square distribution to be an appropriate model for the test statistic's sampling distribution.
KEY TAKEAWAY
Think of expected counts as the blueprint for a building and observed counts as the building you actually constructed. The chi-square statistic measures how much your real structure deviates from the blueprint. But if the blueprint is drawn on flimsy paper—meaning the conditions for inference are not met—then no matter how carefully you measure the deviations, your conclusions about structural integrity will be unreliable. Verifying conditions is like ensuring the blueprint is drawn to scale before you compare.

Visualizing Expected vs. Observed Counts

A powerful way to build intuition for expected counts is to visualize how they compare to observed counts across multiple categories. The diagram below presents a side-by-side bar chart for a hypothetical goodness-of-fit scenario: a die-rolling experiment with n = 120 rolls. Under the null hypothesis that the die is fair, each face has probability 1/6, yielding an expected count of 20 per face. The observed counts, drawn from actual data, deviate from this uniform expectation, and the chi-square statistic quantifies whether those deviations are larger than chance alone would produce.

Each pair of bars shows the observed count (violet) and expected count (cyan, uniformly 20) for each die face. Faces 3 and 6 deviate most from expectation, contributing the largest components to the chi-square statistic.

Notice that the expected count line sits at 20 for every face—a direct consequence of the null hypothesis asserting equal probability across all six outcomes. The observed counts scatter above and below this reference. Each cell's contribution to the chi-square statistic is (O − E)² / E; cells with larger absolute deviations from the expected count, such as Face 3 (O = 27) and Face 6 (O = 14), dominate the sum. Visualizing the data this way reinforces a crucial insight: the chi-square statistic aggregates squared, standardized discrepancies across all categories, and it is the pattern of deviations—not any single category—that drives the result.

Mathematical Framework

The computation of expected counts differs depending on which chi-square test you are conducting. We present the formulas for the two most common settings: the goodness-of-fit test (one categorical variable) and the test of independence or homogeneity (two categorical variables in an r × c table). In both cases, the expected count for a cell represents the count that would be predicted if the null hypothesis held exactly, scaled by the sample size.

Goodness-of-Fit Expected Counts

GOODNESS-OF-FIT EXPECTED COUNT
Eᵢ = n × p₀ᵢ
where Eᵢ is the expected count for category i, n is the total sample size, and p₀ᵢ is the hypothesized proportion for category i under H₀. The sum of all p₀ᵢ must equal 1.

Two-Way Table Expected Counts

INDEPENDENCE / HOMOGENEITY EXPECTED COUNT
Eᵢⱼ = (Rᵢ × Cⱼ) / n
where Eᵢⱼ is the expected count for the cell in row i and column j, Rᵢ is the total for row i, Cⱼ is the total for column j, and n is the grand total. This formula follows from the multiplication rule for independent events: if the row and column variables are independent, the joint probability of cell (i, j) is (Rᵢ/n) × (Cⱼ/n), and the expected count is n times that product.

The Chi-Square Test Statistic

CHI-SQUARE TEST STATISTIC
χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ
The summation runs over all cells (or categories). Each term measures the squared deviation of the observed count from the expected count, divided by the expected count. Division by Eᵢ standardizes the contribution so that cells with larger expected counts do not automatically dominate. Under H₀ and when conditions are met, this statistic follows approximately a χ² distribution with the appropriate degrees of freedom.
💡 Why Divide by E?
Dividing by the expected count accomplishes standardization. A deviation of 5 from an expected count of 10 is far more noteworthy than a deviation of 5 from an expected count of 500. The ratio (O − E)² / E places every cell on a common scale, analogous to converting raw scores to z-scores in the continuous setting.

Conditions for the Chi-Square Test

The chi-square test statistic only follows the χ² distribution approximately, and that approximation degrades when certain conditions are violated. Before reporting a p-value or making a reject/fail-to-reject decision, you must verify three categories of conditions. Failing to check these conditions is one of the most common errors in applied categorical analysis and can lead to inflated Type I error rates or diminished power.

The three pillars of chi-square validity: randomness ensures generalizability, independence ensures the multinomial model applies, and the large-counts condition ensures the chi-square distribution adequately approximates the discrete sampling distribution.

Condition Details

The randomness condition requires that the data arise from a probability-based sampling mechanism or a randomized experiment. Without random selection, the sample may not represent the population, and without random assignment, confounding variables may explain observed differences between groups. In practice, you should state how the data were collected and confirm that randomization was employed.

The independence condition demands that each observation provides information independent of all other observations. When sampling without replacement from a finite population, this is approximately satisfied provided the sample is no more than 10% of the population (the 10% condition). Matched or repeated-measures designs violate independence and require alternative methods such as McNemar's test.

The large counts condition (also called the large-sample condition) stipulates that every expected count must be at least 5. This threshold, rooted in Cochran's 1954 guidelines, ensures that the continuous χ² distribution provides a close approximation to the discrete distribution of the test statistic. If any expected count falls below 5, remedies include combining sparse categories, collecting a larger sample, or switching to an exact test (e.g., Fisher's exact test for 2 × 2 tables). Note that this condition concerns expected counts, not observed counts—a frequent source of student confusion.

⚠️ Common Mistake
Students often check whether each observed count is at least 5. This is incorrect. The large-counts condition applies to the expected counts. You can have an observed count of 0 in a cell; what matters is whether the expected count for that cell is at least 5.

Worked Example — Two-Way Table

A university dining services office surveys a random sample of 400 students about their preferred meal plan (Unlimited, 14-Meal, or 8-Meal) and their year in school (Underclass: first-year or sophomore; Upperclass: junior or senior). The administrators want to know whether meal-plan preference is independent of class standing. Below is the observed two-way table.

Observed counts for meal plan preference by class standing (n = 400)
Unlimited14-Meal8-MealRow Total
Underclass1209040250
Upperclass506040150
Column Total17015080400
Computing Expected Counts & Checking Conditions
1
Step 1 — Compute Expected Counts Using E = (R × C) / nApply the formula Eᵢⱼ = (Row total × Column total) / Grand total for each of the six cells. Underclass–Unlimited: E = (250 × 170) / 400 = 42,500 / 400 = 106.25 Underclass–14-Meal: E = (250 × 150) / 400 = 37,500 / 400 = 93.75 Underclass–8-Meal: E = (250 × 80) / 400 = 20,000 / 400 = 50.00 Upperclass–Unlimited: E = (150 × 170) / 400 = 25,500 / 400 = 63.75 Upperclass–14-Meal: E = (150 × 150) / 400 = 22,500 / 400 = 56.25 Upperclass–8-Meal: E = (150 × 80) / 400 = 12,000 / 400 = 30.00
Expected counts: 106.25, 93.75, 50.00, 63.75, 56.25, 30.00
2
Step 2 — Verify the Sum of Expected CountsA useful sanity check: the sum of all expected counts must equal the grand total. 106.25 + 93.75 + 50.00 + 63.75 + 56.25 + 30.00 = 400. ✓
Sum = 400 ✓
3
Step 3 — Check the Randomness ConditionThe problem states that the dining services office surveyed a random sample of 400 students. This satisfies the randomness condition.
Randomness: Satisfied ✓
4
Step 4 — Check the Independence (10%) ConditionBecause we are sampling without replacement, we need n ≤ 10% of the population. A university typically has well over 4,000 students, so 400 ≤ 10% of the student body. Independence is plausible.
Independence: Satisfied ✓ (400 < 10% of population)
5
Step 5 — Check the Large Counts ConditionExamine every expected count: 106.25, 93.75, 50.00, 63.75, 56.25, and 30.00. The smallest expected count is 30.00, which is well above 5. The large counts condition is satisfied.
Large Counts: Satisfied ✓ (minimum E = 30.00 ≥ 5)
6
Step 6 — Compute the Chi-Square Statisticχ² = (120 − 106.25)² / 106.25 + (90 − 93.75)² / 93.75 + (40 − 50)² / 50 + (50 − 63.75)² / 63.75 + (60 − 56.25)² / 56.25 + (40 − 30)² / 30 = 1.778 + 0.150 + 2.000 + 2.966 + 0.250 + 3.333 = 10.477
χ² ≈ 10.48, df = (2 − 1)(3 − 1) = 2, p ≈ 0.0053

Because all three conditions are met, we can trust the chi-square approximation. With χ² ≈ 10.48 on 2 degrees of freedom, the p-value is approximately 0.0053, providing strong evidence against the null hypothesis of independence. We conclude that there is a statistically significant association between class standing and meal-plan preference at any conventional significance level.

Strengths, Limitations & Remedies

The chi-square test is remarkably versatile, but like all statistical procedures it has both strengths and limitations. Understanding these trade-offs allows you to choose the right tool for a given dataset and to interpret results responsibly.

Strengths, limitations, and remedies for chi-square tests
StrengthsLimitationsPossible Remedies
Works with nominal (unordered) categorical data where parametric tests cannot be applied.Does not measure the strength or direction of an association; only tests whether one exists.Supplement with Cramér's V or phi coefficient to quantify effect size.
Generalizes easily to tables of any dimension (r × c) and to goodness-of-fit with many categories.Requires all expected counts ≥ 5; sparse tables with low expected counts violate the large-counts condition.Combine sparse categories, increase sample size, or use Fisher's exact test.
Simple to compute by hand and widely available in every statistical software package.Sensitive to sample size: very large samples may yield statistical significance for trivially small deviations.Report effect sizes alongside p-values to distinguish practical from statistical significance.
Assumptions are transparent and easy to check before conducting the test.Cannot handle paired or matched data; observations must be independent.Use McNemar's test for matched-pair categorical data.
KEY TAKEAWAY
Think of the chi-square test as a smoke detector for associations in categorical data: it reliably alerts you when observed counts diverge meaningfully from expected counts, but it does not tell you the source of the fire or how large it is. For that, you need follow-up analyses—residual inspection and effect-size measures—just as a firefighter needs to investigate after the alarm sounds. And like a smoke detector, the chi-square test only functions properly when installed correctly: violating the conditions is like removing the batteries.

Connection to Advanced Theory

The expected-count machinery and conditions you have learned generalize naturally into more advanced frameworks. Understanding where the introductory chi-square test sits within the broader statistical landscape clarifies both its power and its boundaries, and prepares you for methods you may encounter in upper-division courses or graduate-level research.

Introductory chi-square concepts and their advanced counterparts
Introductory Chi-SquareAdvanced Extension
Pearson χ² statistic: Σ (O − E)² / ELikelihood-ratio G² statistic: 2 Σ O × ln(O / E). Asymptotically equivalent to χ² but preferred in log-linear modeling and when nested models are compared.
Expected counts computed from marginal totals assuming independence.Log-linear models parameterize expected counts using main effects and interaction terms, accommodating multi-way tables with three or more categorical variables.
All expected counts ≥ 5 for valid approximation.Exact tests (Fisher's, Freeman-Halton) and permutation tests are used when expected counts are too small, providing exact p-values without distributional assumptions.
Binary or polytomous outcome with no ordinal structure assumed.Cochran-Armitage trend test and ordinal logistic regression exploit the ordering of categories, often yielding greater power when the response is ordinal.

Mastering expected counts and conditions at the introductory level provides the conceptual foundation for these advanced methods. In particular, the logic of comparing observed to expected under a model carries directly into generalized linear models, where the expected cell counts are expressed as functions of model parameters and the deviance (based on G²) replaces the familiar χ² in model-selection contexts. Regardless of the complexity of the method, the fundamental question remains unchanged: are the observed data compatible with what the model predicts?

Practice Problems

PROBLEM 1CONCEPTUAL
A student checks the conditions for a chi-square test and notes that one of the observed counts is 3. She concludes that the large-counts condition is violated. Is she correct? Explain.
PROBLEM 2BASIC CALCULATION
A genetics researcher crosses two pea plants and expects offspring in a 9:3:3:1 phenotypic ratio. She observes 160 offspring. Compute the expected count for each phenotype category.
PROBLEM 3INTERMEDIATE
A 3 × 2 contingency table has row totals of 80, 60, and 60, column totals of 100 and 100, and a grand total of 200. Compute all six expected counts and determine the degrees of freedom for the chi-square test of independence.
PROBLEM 4APPLIED
A public health researcher surveys a random sample of 500 adults (from a city of 250,000) about flu vaccination status (vaccinated or not) and whether they contracted the flu that season (yes or no). The observed data are: Vaccinated & Flu = 15, Vaccinated & No Flu = 210, Not Vaccinated & Flu = 45, Not Vaccinated & No Flu = 230. Compute the expected counts for all four cells, verify all three conditions for a chi-square test, and identify any potential concerns.
PROBLEM 5CRITICAL THINKING
A researcher conducts a goodness-of-fit test with 5 categories and n = 30. Under H₀, the hypothesized proportions are 0.50, 0.20, 0.15, 0.10, and 0.05. Compute the expected counts and explain whether the chi-square test is appropriate. If not, propose two distinct strategies to address the problem and discuss the trade-offs of each.

Summary & Review

The expected count for a chi-square test represents the frequency you would anticipate in each cell if the null hypothesis were exactly true. For a goodness-of-fit test, compute E = n × p₀; for a test of independence or homogeneity, compute E = (row total × column total) / grand total. The chi-square statistic χ² = Σ (O − E)² / E aggregates the standardized squared deviations across all cells, and larger values provide stronger evidence against H₀.

Before interpreting any chi-square result, verify three conditions: randomness (data from a random sample or randomized experiment), independence (observations are independent; if sampling without replacement, n ≤ 10% of the population), and the large counts condition (every expected count is at least 5). When the large-counts condition fails, consider combining categories, increasing the sample size, or using an exact test. Remember: the condition applies to expected counts, not observed counts.

Varsity Tutors • College Statistics • Expected Counts for Chi-Square — Expected Counts and Conditions for Chi-Square