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

  1. Save a category dictionary and document any excluded or merged categories.
  2. Compare observed and expected totals before calculating a statistic.
  3. Inspect zero or small expected cells.
  4. Record the chosen divergence statistic and why it matches the plan.
  5. 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.

Related reading

Reading path: Analyze data. Guide 239 of 242. Choose any guide to suit your project.

Statistical Methods

Check Expected Counts Before a Contingency-Table Test

Audit category counts, independence, and sparse cells before interpreting a categorical association test.

Statistical Methods

Assess Distributional Sensitivity Before Bartlett\u2019s Variance Test

Practical steps and a worked example: Keep a normal-theory variance comparison separate from robust spread checks.

Browse this reading pathTools for this stageGuides and downloads for this stage