Chi-Square Goodness-of-Fit Lab

Categorical Inference 1-Variable Multinomial

Evaluate whether observed category counts follow a hypothesized equal split or custom market benchmarks, and pinpoint which categories drive the discrepancy.

👨‍🏫 Professor Mode: Guided Learning Experience

New to categorical inference? Enable Professor Mode for step-by-step guidance on observed vs. expected counts, cell contributions, and primary drivers!

OVERVIEW & WHAT THIS TOOL SOLVES

Whenever you launch five beverage flavors, staff customer support across seven days of the week, or compare your customer base against regional census tiers, you start with a benchmark expectation—such as an equal split across flavors or historical industry shares. Raw category counts always bounce around from sample to sample, so how do you know if a flavor breakout is real preference or just random luck? The Chi-Square Goodness-of-Fit Test checks whether observed customer counts deviate significantly from your hypothesized distribution and pinpoints the exact category driving the surprise.

🎯 Questions It Answers

  • Do customer choices across our product flavors or channels follow an equal split, or do buyers significantly favor specific options?
  • Does our customer segment breakdown match our target market benchmark or historical category shares?
  • Which specific category (cell) is the primary driver responsible for shattering our baseline expectation?

📂 What Data You Need

  • Category Counts (2+ Categories): Observed customer, transaction, or event counts across mutually exclusive categories.
  • Hypothesized Proportions: Either an equal-split baseline (e.g., 20% each across 5 options) or custom benchmark percentages summing to 100%.
  • Expected Count Check: At least 5 expected observations per category recommended (Cochran's Rule).

💡 What You'll Discover

  • Omnibus Chi-Square Verdict: Test statistic, degrees of freedom, exact p-value, and Cohen's w effect size.
  • Cell-by-Cell Driver Breakdown: Expected counts, raw residuals, standardized residuals, and percentage contribution to the total Chi-Square.
  • Observed vs. Expected Visuals: Side-by-side frequency bars and sampling distribution curves.
🔍 Key Nuances: Omnibus vs. Cell Drivers & Cochran's 5-Per-Cell Rule

Observed vs. Expected

Every test compares what your registers actually rang up against what your null model predicted. The bigger the divergence across categories, the stronger the evidence against the benchmark split.

Why Gaps Are Squared

We square each category's gap, divide by its expected count, and sum across all categories so customer surpluses in one category never cancel out deficits in another.

The Driver Matters Most

Knowing p < 0.001 only tells you the overall distribution broke. Inspecting each category's standardized residual and component share reveals which specific product or day caused the blowout.

  • Cochran's 5-Per-Cell Rule: The Chi-Square distribution relies on a continuous approximation of discrete counts. Every category should have an expected count of at least 5; when an expected count is tiny, dividing by it inflates the test statistic and risks a false alarm.
  • Counts, Not Percentages: Always enter raw observed counts (e.g., 140 shoppers) rather than percentages (e.g., 28%) in the Observed column so the test properly accounts for sample size.
📐 Under the Hood: Model Equations & Variable Definitions
1. Omnibus Chi-Square Discrepancy & Standardized Cell Residual
\[ \chi^2 = \sum_{i=1}^{k} \frac{(O_i - E_i)^2}{E_i} \quad (\text{with } E_i = N \cdot p_{0i},\;\; df = k - 1), \qquad r_i = \frac{O_i - E_i}{\sqrt{E_i}} \]
💬 Read it in plain English: For each category i, we compare observed count Oi against benchmark expected count Ei; summing the squared relative gaps gives the overall χ2 statistic, while the signed residual ri shows whether a specific category over-performed (+2 or higher) or under-performed (−2 or lower).
Oi, N
Observed Category Count & Total Sample YOUR DATA ⓘ
Actual headcount or events recorded in category i (Oi) and total sample size across all categories (N).
Ei, p0i
Expected Count & Null Proportion YOUR DATA ⓘ
Benchmark count expected in category i (Ei = N · p0i) if the null distribution holds true.
χ2, df, k
Omnibus Chi-Square Statistic & Degrees of Freedom INFERENCE ⓘ
Total discrepancy summed across all k categories, tested with df = k − 1 degrees of freedom.
ri
Standardized (Pearson) Cell Residual OUTPUT ⓘ
Signed z-like divergence score for category i showing which specific cells drive the omnibus result.

DATA SOURCE & CASE STUDIES

Case Study Scenario

INPUTS & CATEGORY FREQUENCIES

Category Frequencies & Component Calculations

Category Name Observed (O) Hypothesized % Expected (E) Residual (O − E) Component ((O − E)² / E)
Edit observed counts directly in table to see results update live.

VISUAL OUTPUT

■ Observed Count (O) ■ Expected Count (E)

TEST RESULTS

Chi-Square (χ²)
—
Sum of squared residuals / E
Degrees of Freedom
—
k - 1 categories
p-Value
—
P(χ² ≥ observed | H₀)
Primary Driver
—
Largest component share
Total Sample (N)
—
Sum of observed counts

🔬 Test Validity & Top Divergence Drivers

Checking cell counts...
Primary Divergence Driver: — —% of total χ²

💡 Managerial Takeaway: While the test evaluates overall fit, marketing and ops interventions should focus on the category driving the highest component share.

APA-Style Statistical Reporting

Managerial Interpretation