Chi-Square Inference
One-line statement: Chi-square inference uses the chi-square () distribution to test hypotheses about categorical data and variances by comparing observed counts to expected counts. Key result in words: When data are grouped into categories, the sum of standardized squared deviations between observed and expected frequencies follows (approximately) a chi-square distribution, enabling goodness-of-fit, independence, and homogeneity tests. Where it applies: Categorical/count data, contingency tables, variance estimation for normal populations. Who/when: Karl Pearson introduced the chi-square goodness-of-fit test in 1900; R.A. Fisher corrected the degrees-of-freedom theory in the 1920s.
A single standardized normal deviation squared, , has a chi-square distribution with 1 degree of freedom. If we standardize each category's deviation and square-and-sum across categories, the result behaves—approximately—like a sum of such squared normals. Large discrepancies between what we observe and what we expect produce large values; rare large values are evidence against the null hypothesis. The whole apparatus reduces complicated categorical comparisons to one number and one reference curve.
Formal Statement
A random variable has a chi-square distribution with degrees of freedom, written , if it is the sum of squares of independent standard normal random variables:
Derivation hint: This is a definition, but being the building block follows from the change-of-variables formula applied to a single density. Its probability density function on is
Derivation hint: This is the Gamma density; obtain it by computing the moment generating function and recognizing it. Here is the gamma function, is a positive integer (the degrees of freedom), is the variable, and is Euler's number. The mean is and the variance is .
For data sorted into mutually exclusive categories with observed counts and expected counts (under the null hypothesis), the Pearson statistic is
Derivation hint: Each term standardizes the deviation by its approximate variance (Poisson-like); summing approximately reproduces a sum of squared normals. where is the observed frequency in category , is the expected frequency, is the total sample size, and is the hypothesized probability of category .
Under the null hypothesis fixed and known, as the sample size , the Pearson statistic in [3] converges in distribution to a chi-square random variable:
Derivation hint: The standardized count vector tends to a multivariate normal with one linear constraint (); the quadratic form of this constrained normal is with degrees of freedom. If the null model contains parameters estimated from the data, the degrees of freedom drop to .
Why It Holds / Derivation
Step 1 — Multinomial setup. The vector of counts follows a multinomial distribution with parameters and , where .
Step 2 — Multivariate CLT. Define the standardized deviations
Derivation hint: This is ; by the multivariate central limit theorem the vector converges to a multivariate normal.
Step 3 — Covariance structure. The limiting normal has mean and covariance matrix , where is the vector of . This matrix is a projection of rank .
Step 4 — Quadratic form. The statistic is . A standard normal vector projected onto an -dimensional subspace yields a quadratic form distributed as :
Derivation hint: The eigenvalues of the projection are ones and one zero; a sum of squared normals with these weights is exactly .
Step 5 — Estimated parameters. Each independently estimated parameter imposes one further linear constraint, lowering the rank—hence the subtraction of from the degrees of freedom.
∎Karl Pearson, founder of the world's first university statistics department at University College London, introduced the chi-square goodness-of-fit test in his 1900 paper "On the criterion that a given system of deviations...". A polymath trained in mathematics and law, Pearson sought objective criteria for judging how well theoretical curves fit real frequency data—motivated by biological and evolutionary problems from his collaboration with Francis Galton and Walter Weldon. His original derivation, however, used degrees of freedom even when parameters were estimated; this error was decisively corrected by Ronald Fisher.
Building Intuition
Imagine rolling a die 600 times. Under fairness you expect 100 of each face. If you get , the deviations are small relative to , so each standardized term is around 1 or less, and their sum is modest. But produces deviations of 50, 40, etc., whose squares dwarf , inflating . The statistic essentially asks: "In units of natural sampling noise, how far off are we, totalled across all categories?" The chi-square distribution tells us how large that total tends to get by chance alone, so an observed value in the far right tail signals a genuine departure from the model.
Worked Examples
Given: A die is rolled times. Observed counts: . Test : the die is fair () at significance .
Step 1 — Expected counts. for each face.
Step 2 — Compute terms.
Step 3 — Degrees of freedom. . No parameters estimated.
Step 4 — Critical value. .
Step 5 — Decision. Since , we fail to reject .
Given: A contingency table of patients:
| Recovered | Not recovered | Row total | |
|---|---|---|---|
| Drug | 50 | 30 | 80 |
| Placebo | 35 | 45 | 80 |
| Col total | 85 | 75 | 160 |
Test independence of treatment and outcome at .
Step 1 — Expected counts : , , , .
Step 2 — Statistic.
Step 3 — Degrees of freedom. .
Step 4 — Critical value. .
Step 5 — Decision. , so reject .
Common Misconceptions
The chi-square test requires sufficiently large expected counts. A common rule of thumb is that every should be at least 5 (some allow a few as low as 1 if most exceed 5). When expected counts are too small, the continuous chi-square approximation to the discrete multinomial is poor and p-values are unreliable. Remedies include combining categories or using Fisher's exact test. Also note: the statistic uses counts, never proportions or percentages—plugging in percentages is a frequent and fatal error.
The chi-square test is not a test of the strength of association. Consider two tables with identical proportions but different sample sizes. With a moderate association may give (not significant), while the same proportions with give (wildly significant). The statistic scales with , so a "significant" result with huge samples can reflect a trivially small effect. Significance importance—report an effect-size measure such as Cramér's alongside the test.
Connections
Chi-square inference sits in a web of related ideas. It is a special case of the Likelihood Ratio Test, whose statistic is asymptotically equivalent to Pearson's . The distribution itself is the Gamma Distribution with shape and scale 2, and squaring a single Standard Normal Distribution variable gives . The ratio of two independent chi-squares (scaled) defines the F-Distribution used in Analysis of Variance, while a normal divided by a scaled chi-square root gives the Student t-Distribution. Inference about a normal variance uses , directly linking it to Confidence Intervals.
Real-World Applications
Historical Development
Subtleties & Limits
The chi-square approximation degrades for sparse tables, and there is no universally agreed threshold for "large enough" expected counts—Cochran's rules are heuristics, not theorems. For multi-way contingency tables, log-linear models and the question of which interaction terms to include push beyond classical chi-square testing into model-selection territory where the asymptotic degrees of freedom may not be integers in practice. Continuity corrections (Yates's correction for tables) remain debated: they can over-correct and reduce power. Modern alternatives—exact permutation tests, Monte Carlo p-values, and Bayesian model comparison—address these limits but raise their own questions about computational feasibility and prior sensitivity in high dimensions.
See Also
Standard Normal Distribution · Gamma Distribution · F-Distribution · Student t-Distribution · Likelihood Ratio Test · Analysis of Variance · Hypothesis Testing · Multinomial Distribution · Fisher's Exact Test