Statistics & Probability / Chi-Squared Goodness of Fit
FREE TO EXPLORE
LABORATORY 29 · STATISTICS & PROBABILITY

Chi-Squared Goodness of Fit theory

Understand chi-squared goodness of fit: probability distributions, theorems, estimation laws, and hypothesis tests.

Probabilistic foundations of Chi-Squared Goodness of Fit.

Pearson's Chi-Squared goodness-of-fit test is the foundational non-parametric method for testing whether empirical frequency data conforms to a hypothesized probability distribution. Formulated by Karl Pearson in 1900, the test measures normalized squared deviations across discrete categories, demonstrating universal asymptotic convergence to the continuous Chi-Squared distribution. In this laboratory, we construct observed-expected frequency tables, evaluate multinomial cell residuals, test Cochran's sample size criteria, and confirm the discrepancy scaling gradient m = 2.400. In mathematical statistics, empirical data science, and modern computational engineering, understanding the asymptotic sampling properties and theoretical behavior of Pearson's Chi-Squared Goodness-of-Fit Test, Multinomial Cell Deviations, and Degrees of Freedom provides crucial guarantees. Rigorous experimental validation connects foundational probability laws with observable empirical phenomena, ensuring that statistical inference remains valid under finite sample sizes and real-world data collection constraints.

y = 2.4000 · x

Viva voce questions & analytical theory

How did Karl Pearson formulate the Chi-Squared goodness-of-fit test in 1900?

In 1900, Karl Pearson revolutionized mathematical statistics by introducing the goodness-of-fit test. Prior to Pearson, deviations between observed data and theoretical distributions were evaluated heuristically without formal probability metrics. Pearson considered a multinomial experiment with n observations categorized into K mutually exclusive classes with observed frequencies O_1, ..., O_K and hypothesized probabilities p_1, ..., p_K. He defined the test statistic χ² = ∑_{i=1}^K (O_i - E_i)^2 / E_i where E_i = n p_i, and proved that as n → ∞, this quadratic form converges in distribution to a Chi-Squared variable with K - 1 degrees of freedom.

Why are degrees of freedom equal to K - 1 rather than K in Pearson's test?

The K observed frequencies are constrained by a single linear conservation condition: the total count must equal the sample size: ∑_{i=1}^K O_i = n. Because the expected counts also satisfy ∑_{i=1}^K E_i = n, the deviations sum to zero: ∑ (O_i - E_i) = 0. This single linear constraint removes one degree of freedom from the K-dimensional multinomial vector. Consequently, the covariance matrix of the cell deviations has rank K - 1, and the asymptotic distribution is χ²(K - 1).

How do estimated parameters alter degrees of freedom in goodness-of-fit testing?

If m unknown parameters of the target distribution must be estimated from the sample data using efficient methods (such as maximum likelihood on the binned counts), each independently estimated parameter imposes an additional linear constraint on the multinomial manifold. As proven by R. A. Fisher in 1922 (correcting Pearson's original assertion), the asymptotic degrees of freedom are reduced to df = K - 1 - m. For example, testing for normality with estimated mean and variance reduces df to K - 1 - 2 = K - 3.

What is Cochran's rule for the validity of the Chi-Squared approximation?

William G. Cochran (1952, 1954) established empirical guidelines for when the continuous Chi-Squared distribution accurately approximates the discrete multinomial deviance: (1) For goodness-of-fit tests, no expected frequency E_i should be less than 1.0 (E_i ≥ 1); and (2) At most 20% of the bins should have expected frequencies less than 5.0 (E_i < 5). If these conditions fail, neighboring bins should be combined (pooled) to ensure sufficient expected counts, or exact multinomial tests should be used.

What is the relationship between standardized residuals and Chi-Squared cell contributions?

The Pearson test statistic can be expressed as the sum of squared standardized residuals: χ² = ∑_{i=1}^K r_i^2, where r_i = (O_i - E_i) / √E_i. Each r_i measures the deviation in units of standard errors. Under H_0, each r_i is asymptotically standard normal N(0, 1) (subject to the linear constraint ∑ √E_i r_i = 0). Examining individual cell residuals r_i allows practitioners to diagnose exactly which categories drive statistical significance.

How does the G-test (likelihood-ratio goodness of fit) compare to Pearson's Chi-Squared test?

The G-test uses the log-likelihood ratio statistic G = 2 ∑_{i=1}^K O_i ln(O_i / E_i). By expanding the natural logarithm in a second-order Taylor series ln(1 + x) ≈ x - x^2/2 where x = (O_i - E_i)/E_i, the G-statistic simplifies to G ≈ ∑ (O_i - E_i)^2 / E_i = χ². Thus, Pearson's test and the G-test are asymptotically equivalent under H_0, although Pearson's test often exhibits slightly superior accuracy in small-to-moderate sample sizes.

How does Pearson's test handle continuous distributions via binning?

To test whether continuous data follows a distribution F(x), the continuous domain is partitioned into K intervals [a_{j-1}, a_j). The expected probabilities are p_j = F(a_j) - F(a_{j-1}). To maximize statistical power and ensure equal expected counts, equiprobable binning (where each bin has expected probability p_j = 1/K) is standard practice. The Kolmogorov-Smirnov test provides an alternative that avoids binning entirely.

Experimental precautions and statistical checks

  • Ensure that expected frequencies are computed as E_i = n p_i and NOT observed frequencies O_i in the denominator.
  • Verify that Cochran's minimum cell count condition (E_i ≥ 5) is met; collapse adjacent bins if counts are too small.
  • Subtract one additional degree of freedom for every population parameter estimated from the sample data.
  • Check that total observed count strictly equals total expected count: ∑ O_i = ∑ E_i = n.

Theoretical assumptions & limitations

  • Binning continuous data into discrete categories discards order information within bins and depends on arbitrary bin choices.
  • The Chi-Squared test is an asymptotic test; in very small samples, exact multinomial probabilities must be used.
↳
Connect theory to empirical data.

The empirical regression of expected Pearson test statistics against discrepancy factor k confirms theoretical test scaling with slope m = 2.4000 and R² = 1.000000.