Statistical Methods
Reconcile Observed and Expected Totals Before a Goodness-of-Fit Test
Define the research task
A categorical goodness-of-fit calculation starts with aligned observed and expected counts. Expected probabilities must correspond to the same categories and total sample size. A discrepancy caused by different totals is a data-reconciliation problem, not evidence against a substantive model. Also distinguish testing fixed probabilities from testing a model whose parameters were estimated from the same observations.
Work through the check
- Save a category dictionary and document any excluded or merged categories.
- Compare observed and expected totals before calculating a statistic.
- Inspect zero or small expected cells.
- Record the chosen divergence statistic and why it matches the plan.
- Account for fitted parameters in the inferential degrees of freedom only when that adjustment is justified.
Do not change the divergence or merge categories after viewing p values without reporting the exploratory choice. A calculation that returns a number can still have an unsuitable reference distribution.
Hypothetical example and reporting
For hypothetical observed counts [12,8] and expected counts [10,10], both totals are 20. Pearson’s statistic is (12−10)²/10 + (8−10)²/10 = 0.8. If the expected vector were [5,5], the total would instead be 10: reconcile that mismatch before continuing. If one free parameter was estimated in a two-category model, a naive one-degree-of-freedom test would need reconsideration.
Source and verification
Method checked 27 November 2026 against SciPy primary documentation: stats.power_divergence. Examples are synthetic; this page does not assert human expert approval.