Tutorials › Introduction to Statistics › Calculating Expected Counts Under a Null Model

Chi-Square Goodness of Fit · Tutorial 800 of 996

Calculating Expected Counts Under a Null Model

Use the null probabilities and total sample size to calculate and interpret the expected count in each category.

Intermediate 10 min read

What You'll Learn

  • Define an expected category count under a specified null model.
  • Calculate expected counts using the sample size and category probabilities.
  • Handle models with equal or unequal category probabilities.
  • Check that expected counts sum to the total sample size.
  • Explain why expected counts can be fractional and are not observed data.
  • Distinguish a category's expected count from its observed count.

Why Calculate Expected Counts?

A goodness-of-fit question compares the category frequencies observed in a sample with frequencies predicted by a specified null model. Before making that comparison, we need to translate the model's probabilities into counts on the scale of the sample. If a null model says that 30% of outcomes fall in a category and the sample contains 100 outcomes, its expected count in that category is 30.

The calculation is simple, but it is important to interpret it correctly. An expected count is a model-based average over repeated samples of the same size. It is not a promise about the exact number that will appear in one sample, and it need not be a whole number. This tutorial focuses on how to calculate and check expected counts when the category probabilities are specified.

Definition: Suppose a sample contains \(n\) observations classified into \(k\) mutually exclusive and collectively exhaustive categories. Under a null model that assigns probability \(p_i\) to category \(i\), the expected count in category \(i\) is \(E_i=np_i\). The observed count \(O_i\) is the number actually recorded in that category.

From Probabilities to Counts

A probability is a proportion on a scale from 0 to 1; a count is a number of observations. Multiplying the probability for a category by the total sample size converts from the first scale to the second. For each category, use the same total \(n\), but multiply by that category's own probability.

$$ E_i = n p_i $$

Here, \(E_i\) denotes the expected count in category \(i\), \(n\) is the total number of observations being classified, and \(p_i\) is the probability of category \(i\) under the null model. The probabilities across all \(k\) categories must add to 1:

$$ \sum_{i=1}^{k} p_i = 1 $$

The categories must also cover every possible outcome being counted, with no outcome belonging to more than one category. If the probabilities describe only some of the possible outcomes, or if categories overlap, they do not form the full probability model required for this calculation. The value of \(n\) must count the observations assigned across those categories.

Expected counts inherit the pattern of the model probabilities. A category with twice the null probability of another category has twice its expected count, for a common sample size. If all categories are equally likely, each has probability \(1/k\) and expected count \(n/k\). If the probabilities differ, each category gets its own product \(np_i\).

Worked Example: Equal Probabilities

Suppose a hypothetical study classifies 120 independent selections into one of four equally likely categories under its null model. Calculate the expected count in each category.

There are four categories and the model assigns equal probability to each, so the probability for each is \(1/4=0.25\). The total sample size is \(n=120\). For any one category,

$$ E_i = n p_i = 120(0.25)=30 $$

Thus the expected counts are 30, 30, 30, and 30. As a check, \(30+30+30+30=120\), the total sample size. These are the counts predicted by the equal-probability model on average; the actual sample need not contain exactly 30 selections in every category.

Unequal Probabilities

The same multiplication applies when categories do not have equal probabilities. In that case, it would be incorrect to divide the sample size equally among the categories. The null model determines what share of the total is expected in each category.

Worked Example: Three Unequally Likely Categories

Imagine a hypothetical sample of 200 items classified as type A, type B, or type C. The null model specifies probabilities 0.50, 0.30, and 0.20, respectively. Calculate each expected count.

The model probabilities add to one: \(0.50+0.30+0.20=1.00\), so they allocate the full sample across the three categories. Apply \(E_i=np_i\) separately:

$$ E_A=200(0.50)=100,\qquad E_B=200(0.30)=60,\qquad E_C=200(0.20)=40 $$

The expected counts are 100 items of type A, 60 of type B, and 40 of type C. Their sum is \(100+60+40=200\). Equal allocation would instead give about 66.7 per category, which would contradict the specified null model. The unequal counts are appropriate because the null model gives the categories unequal probabilities.

A useful way to organize a calculation is to write the categories, their null probabilities, and their expected counts in matching order. That makes it easier to notice if a probability has been paired with the wrong category or if a count has been calculated from the wrong value of \(n\).

CategoryNull probabilityExpected count when \(n=200\)
A0.50100
B0.3060
C0.2040
Total1.00200

Why the Formula Works

The formula \(E_i=np_i\) follows from the definition of expected value. For each observation \(j\), define an indicator variable \(I_{ij}\) that equals 1 if observation \(j\) falls in category \(i\), and 0 otherwise. The count in category \(i\) is the sum of these indicators: each observation contributes one if it is in the category and zero if it is not.

$$ O_i = \sum_{j=1}^{n} I_{ij} $$

Under the null model, each observation has probability \(p_i\) of belonging to category \(i\). Therefore \(I_{ij}\) is a 0-or-1 variable with expected value \(p_i\): it equals 1 with probability \(p_i\) and 0 with probability \(1-p_i\). The expected value of the sum is the sum of the expected values, so:

$$ E(O_i) = E\left(\sum_{j=1}^{n} I_{ij}\right) = \sum_{j=1}^{n} E(I_{ij}) = \sum_{j=1}^{n} p_i = n p_i $$

This establishes the expected count formula. The argument uses the same category probability \(p_i\) for each observation; it does not require the indicator variables to be independent for this expected-value calculation. Independence is a separate feature of common sampling models, not a step needed to add these expectations.

Worked Example: Fractional Expected Counts

A hypothetical sample contains 73 observations. Under a three-category null model, the probabilities are 0.50, 0.30, and 0.20. Find the expected counts and explain a non-integer result.

First verify that the probabilities account for all categories: \(0.50+0.30+0.20=1.00\). Then multiply each probability by \(n=73\):

$$ E_1=73(0.50)=36.5,\qquad E_2=73(0.30)=21.9,\qquad E_3=73(0.20)=14.6 $$

The expected counts are 36.5, 21.9, and 14.6. Their sum is \(36.5+21.9+14.6=73.0\), as required. A single sample cannot contain half an observation in a category. That does not make 36.5 an error: it is the average count the model predicts for that category across repeated samples of 73 observations, not a claim that this particular sample has a fractional count.

Checks and Interpretation

Before using a set of expected counts in a comparison with observed data, check the inputs and arithmetic. Each expected count should come from the null probability assigned to that category and the full sample size used in the analysis. The following checks are useful:

  • Check the probability total. The category probabilities should add to 1, allowing for small discrepancies caused by rounding when probabilities are reported approximately.
  • Check the sample total. Use the number of observations classified across the stated categories, not the number in one category or a different group.
  • Check each product. Calculate \(np_i\) for every category rather than distributing \(n\) evenly unless equal probabilities are actually specified.
  • Check the expected-count total. When the probabilities sum to 1, the expected counts sum to \(n\): \(\sum_{i=1}^{k}E_i=n\sum_{i=1}^{k}p_i=n\).
  • Keep observed and expected counts distinct. Observed counts come from the data; expected counts come from the null model and sample size.

The sum check is an important diagnostic, but it cannot catch every mistake. For instance, swapping two probabilities between categories can leave the total expected count unchanged. Always keep the probability and category labels together as well as checking the total.

Expected counts also help express the null model in terms that can be compared with observed frequencies. If the model assigns probability 0.20 to a category in a sample of 73, the model's expected count is 14.6. This does not tell us what the sample actually contained; that information must come from the observed data. The distinction is central whenever a statistical method compares what was seen with what a model predicts.

Common Mistakes

  • Dividing the sample size equally by default. This is appropriate only if the null model assigns equal probabilities. With unequal probabilities, calculate \(np_i\) for each category.
  • Rounding a fractional expected count into an observed count. An expected count is a model-based average, so it may be fractional. Keep the calculated value when reporting it; do not invent or alter observations.
  • Using the observed proportion as though it were the null probability. The expected count uses the probability specified by the null model. The observed proportion describes the sample and is a different quantity.
  • Using a different total for different categories. For one set of categories, each expected count uses the same total \(n\). A category's probability changes the product, not the total sample size.
  • Treating a correct total as proof that every calculation is correct. The expected counts may sum to \(n\) even if probabilities were assigned to the wrong category. Check labels and individual products too.
Key takeaway: Under a null model with specified category probabilities, multiply each category's probability by the total sample size: \(E_i=np_i\). The resulting expected counts describe model-based averages, may be fractional, and sum to \(n\) when the probabilities cover all categories and sum to 1.

Check Your Understanding

Answer these questions by applying the expected-count definition and explaining what the results mean.

  1. A null model assigns probabilities 0.60 and 0.40 to two categories, and \(n=50\). What is the expected count in each category? Verify the total.
  2. A model gives probabilities 0.25, 0.25, 0.25, and 0.25 for a sample of 84. Calculate the expected count per category and explain why equal allocation is justified here.
  3. For \(n=65\), the null probabilities are 0.10, 0.30, and 0.60. Calculate all three expected counts and check their sum.
  4. In your own words, why can an expected count be 12.5 even though a sample cannot contain half an observation?
  5. A student calculates expected counts from observed sample proportions instead of the probabilities specified by the null model. What is wrong with that reasoning?