Why Category Definitions Come First
A goodness-of-fit test compares observed counts with counts predicted by a probability model. Before making that comparison, the outcomes being counted must be defined. If one outcome could be placed in two categories, or some valid outcomes have nowhere to go, the counts do not describe a coherent partition of the observations. A calculation cannot repair that problem.
Category definitions also determine which outcomes the model says are possible. That matters especially when a category has a count of zero. A possible outcome may simply not occur in a particular sample. A structural zero, in contrast, represents an outcome that cannot occur in the population or process under study. Those two kinds of zero have different meanings and different consequences for the model.
“Eligible observation” refers to the set of units the question is about. For example, if the question concerns the outcome of each completed appointment, an appointment with a missing outcome does not automatically belong in a substantive outcome category. Missingness needs a deliberate treatment: it might be excluded under a stated rule, or represented as its own category if the question and model include it.
A category should have a clear assignment rule. “Other” can be useful when it is defined so that it collects valid outcomes not listed individually. But it should not be a vague place to put inconvenient observations after the counts are known. Likewise, a category that is a combination of other categories must not overlap with them unless the categories are redesigned as a single partition.
Categories and the Goodness-of-Fit Model
For a one-way goodness-of-fit test, let \(O_i\) be the observed count in category \(i\), and let \(p_i\) be its probability under the null model. If the total sample size is \(n\), the expected count is \(E_i=np_i\). The Pearson goodness-of-fit statistic compares the observed and expected counts across categories with positive null probabilities.
This expression is defined for categories with \(p_i>0\), because those categories have positive expected counts. A structural-zero category has \(p_i=0\): the model says it cannot occur. Such a category is not an ordinary category with a small probability. It is outside the model’s possible outcomes and should not be treated as a regular term in the statistic.
Before using a chi-square reference distribution, the design and data must also satisfy the conditions for that calibration, including the relevant independence and expected-count requirements. Those conditions are separate from good category construction: mutually exclusive and exhaustive categories are necessary, but they do not by themselves guarantee valid inference. When the approximation is unsuitable, exact or simulation-based methods may be considered under their appropriate assumptions.
A Zero Count Is Not Necessarily a Structural Zero
An observed count \(O_i=0\) means that no sampled observation fell in category \(i\). If the category was possible under the null model, its probability is positive and its expected count is positive. A sample can still happen to contain no such observations. The zero is data; it does not change the category’s definition or the null probability.
A structural zero is different. It arises from the design or from a genuine constraint on the process: under the stated scope of the study, that outcome cannot occur. In the model, its probability is exactly zero. For example, if a study is restricted to transactions at a cashless online checkout, payment by physical cash is impossible within that defined setting. The zero is not an accidental feature of the sample; it follows from the setup.
The distinction depends on the population and process being modeled, not merely on the observed table. A category with no observations is not structural just because its count is zero. Conversely, if the study design rules out an outcome, a large sample cannot make that outcome a possible category under the model.
Worked Example: A Possible Category Has No Observations
Suppose a hypothetical clinic samples 60 appointment slots under a policy that allows in-person visits, video visits, and cancellations. The null model assigns probabilities \(0.50\), \(0.20\), and \(0.30\), respectively. The observed counts are 36 in-person visits, 0 video visits, and 24 cancellations. Assume the slots were sampled independently and the outcome categories are recorded consistently.
Check the categories. A slot ends in exactly one of the three recorded outcomes, and every slot has an outcome, so these categories are mutually exclusive and exhaustive. Video visits are allowed by the policy, so video is possible even though its observed count is zero.
Find expected counts. With \(n=60\), the expected counts are \(60(0.50)=30\), \(60(0.20)=12\), and \(60(0.30)=18\). Each is at least 5, so the common expected-count guideline for chi-square calibration is met in this example.
The video category contributes 12 to the statistic. Its zero count is a substantial departure from its expected count of 12, but the calculation is valid because the null probability is positive. The statistic summarizes the discrepancy; a conclusion about statistical significance would require comparing it with the appropriate reference distribution under the test’s conditions.
Why a Structural Zero Cannot Be Handled Like an Ordinary Zero
The distinction follows directly from the model. If \(p_i>0\), then the expected count is \(np_i>0\). When \(O_i=0\), the category’s Pearson contribution is
This is a defined, finite contribution. Also, under independent sampling with category probability \(p_i>0\), the probability of observing no cases in that category is \((1-p_i)^n\), which is positive for finite \(n\). A zero count is therefore possible even when the null model assigns a positive probability to the category.
If instead \(p_i=0\), then the expected count is \(np_i=0\). Substituting \(O_i=0\) into the Pearson term gives \(0/0\), which is undefined. More fundamentally, the null model assigns probability zero to any observation in that category: if \(p_i=0\), then the probability of at least one case there is zero. The category should be removed from the model’s support, meaning the set of outcomes the model allows, rather than added to the ordinary sum.
This does not mean a structural-zero category can be ignored without checking the data. If the data table records a positive count in an outcome that the model declares impossible, the stated model and the recorded data conflict. The conflict must be investigated before a test is run.
Worked Example: A Category Excluded by the Study Design
A hypothetical analysis concerns only transactions completed at a cashless online checkout. The null model assigns probability \(0.70\) to card payment and \(0.30\) to digital-wallet payment. Physical cash is ruled out by the checkout design, so it is structural-zero rather than a third possible payment method in this study. Suppose the table lists 100 transactions: 68 card, 30 digital wallet, and 2 cash.
Check the stated model against the table. Card and digital-wallet counts total \(68+30=98\), not 100. The remaining 2 observations are coded as cash, even though cash is impossible under the stated scope. The expected counts for the two permitted outcomes would be \(100(0.70)=70\) and \(100(0.30)=30\), but those are not a partition of the observed data as recorded.
Do not calculate a Pearson statistic by adding cash as a category. Its expected count would be \(100(0)=0\), so its term would divide by zero. Nor should the two cash-coded records simply be discarded: doing so would change the sample size and potentially the data being analyzed without justification.
The records need to be checked. Perhaps “cash” is a miscoding of one of the allowed methods. If the records are corrected according to a documented rule, the analysis can be reconsidered with the resulting counts. If the two transactions really were paid in cash, then they do not belong to the stated cashless-online population; the sample scope or the model must be revised. Until the discrepancy is resolved, the proposed goodness-of-fit comparison is not valid.
Choosing Categories Before Looking at the Counts
Category definitions should follow the scientific question and the data-collection process. They should not be chosen simply to make a test statistic smaller or a result appear more favorable. Looking at observed counts first and then changing boundaries can make the reported test fail to reflect the intended question: the data have influenced how the outcomes are grouped.
A useful planning sequence is to specify the study scope, list the possible outcomes within that scope, and write a rule assigning each eligible observation to exactly one outcome. Then state the null probability for each possible category. A category that is impossible under this scope can be identified as structural and excluded from the model’s support; a possible category remains in the model even if its observed count later turns out to be zero.
State which units and outcomes the analysis concerns. This identifies what counts as an eligible observation.
Write assignment rules so categories are mutually exclusive and exhaustive for the eligible observations.
Give each possible category its null probability. Investigate any category that the design makes impossible rather than assigning it a small positive probability.
Classify a zero count in a possible category as a sample outcome. Treat a positive count in a structural-zero category as a model-data discrepancy to resolve.
The number of categories in the model is the number of possible outcomes being compared, not automatically the number of labels printed in a raw data table. Removing a structural-zero outcome from the support changes the set of categories in the model. It does not justify treating every small or empty category as structural.
Worked Example: Checking a Category Plan for Completeness
A hypothetical survey asks 80 randomly selected people how they reached a community event. The planned categories are “walked,” “used public transport,” and “drove.” Suppose the recorded counts are 18, 22, and 31, respectively, while 9 people arrived by bicycle.
Check exclusivity. If respondents are instructed to report one primary travel mode, each response can be assigned to only one category. Without such a rule, someone who walked to a bus stop and then used public transport might fit two labels.
Check exhaustiveness. As written, the categories are not exhaustive because bicycle travel is a valid outcome with no category. The three counts total \(18+22+31=71\), leaving 9 observations unassigned. A goodness-of-fit test based on those three counts would not describe all 80 people.
The category plan must be revised according to the question and the data protocol. For example, it could include a clearly defined “bicycled” category, and any other valid travel modes would also need a specified destination. If a meaningful “other mode” category was set up in advance, it could collect outcomes not listed separately. The important point is that all 80 responses need an unambiguous place in the partition before the observed counts are compared with a probability model.
Common Mistake: Calling Every Zero a Structural Zero
Wrong reasoning: “No one in the sample used a digital wallet, so digital-wallet use must be impossible and the category should be removed.” The conclusion does not follow from the observed count. A sample count of zero says only that no sampled case fell in the category.
Correction: Ask whether the outcome could occur under the study design and population, and examine the null model. If it is possible and \(p_i>0\), keep the category in the model even when \(O_i=0\); its expected count is positive and its Pearson contribution is defined. If the design truly rules it out and \(p_i=0\), it is structural and is excluded from the support. If the data show cases in that category anyway, resolve the contradiction before testing.
Check Your Understanding
Answer each question using the distinction between the sample table and the model’s possible outcomes.
- A possible outcome has null probability \(0.10\), but its observed count is zero. Is it a structural zero? Explain.
- Why must categories be mutually exclusive and exhaustive before observed counts can be compared with a probability model?
- A study’s design rules out an outcome, so its null probability is zero. Why is its Pearson contribution not calculated as an ordinary term?
- A category declared impossible by the study design has a positive recorded count. What should be checked before conducting a goodness-of-fit test?
- A table of travel modes omits bicycle travel, although some sampled people bicycled. What property of the categories fails, and why does that matter?