Chi-squared test
Statistical test for independence in contingency tables.
The chi-squared test (also chi-square or χ2 test) is a statistical hypothesis test used in the analysis of contingency tables when sample sizes are large. It examines whether two categorical variables are independent in influencing the test statistic. The test is valid when the test statistic is chi-squared distributed under the null hypothesis, specifically Pearson's chi-squared test and variants thereof.
- field
- Statistics
- known_for
- Pearson's chi-squared test, goodness of fit test
Lore & Background
In the 19th century, statistical analytical methods were mainly applied in biological data analysis, and researchers customarily assumed observations followed a normal distribution. Karl Pearson investigated a test of goodness of fit, proposing that under the null hypothesis, as n → ∞, the limiting distribution of the quantity X² = Σ (x_i - m_i)² / m_i follows the χ2 distribution with k − 1 degrees of freedom, where x_i are observed frequencies and m_i are expected frequencies. However, Pearson's original view on degrees of freedom was flawed. It was Ronald Fisher who later identified the issue and provided the correct adjustment: when parameters are estimated from the sample, the degrees of freedom must be reduced by the number of estimated parameters. For example, if r parameters are estimated, the correct degrees of freedom become k − 1 − r, not simply k − 1. Pearson had considered cases where expected numbers depended on parameters estimated from the sample, suggesting that the difference between X² and X'² would usually be positive and small enough to omit, but this omission is now known to be incorrect.
Reader's Guide
The chi-squared test is a foundational tool in statistics, primarily used to determine whether there is a statistically significant difference between expected and observed frequencies in one or more categories of a contingency table. Pearson's work allowed researchers to model skewed distributions and test goodness of fit, providing a method that remains widely applied today. The test's validity relies on the test statistic being chi-squared distributed under the null hypothesis, with the approximation improving as sample sizes increase. For smaller sample sizes, Fisher's exact test is used instead. The chi-squared test is also applied to test the null hypothesis of independence of a pair of random variables based on observations of the pairs. Despite its utility, Pearson's handling of estimated parameters led to a controversy that took two decades to resolve, highlighting the importance of rigorous statistical theory. The test's legacy endures as a standard method for categorical data analysis across many fields.
Did You Know?
- The chi-squared test is used to examine whether two categorical variables are independent in influencing the test statistic.
- For contingency tables with smaller sample sizes, a Fisher's exact test is used instead of the chi-squared test.
- The test statistic X² = Σ (x_i - m_i)² / m_i follows the χ2 distribution with k − 1 degrees of freedom as n becomes large, but when parameters are estimated from the sample, the degrees of freedom must be reduced by the
Purpose and Core Application
The chi-squared test stands as a cornerstone of categorical data analysis, designed to answer a deceptively simple question: do two variables truly influence each other, or is any apparent association merely a product of chance? At its heart, the test operates on contingency tables—structured grids where observations are sorted into mutually exclusive classes along two dimensions. The null hypothesis posits that no meaningful difference exists between the classes in the underlying population. The test statistic then quantifies how far the observed frequencies deviate from what would be expected if that null hypothesis held true. A statistically significant result signals that the pattern of counts across categories is unlikely to have arisen by random fluctuation alone, suggesting the two categorical dimensions are not independent. This framework makes the chi-squared test indispensable whenever researchers need to assess relationships between discrete, non-numeric variables without assuming any particular shape for the underlying distribution.
Historical Origins and Pearson's Contribution
Before the turn of the twentieth century, statistical practice in biology and related fields was dominated by a single assumption: that observations naturally followed a normal distribution. Pioneers like Sir George Airy and Mansfield Merriman built their analytical work on this premise, but Karl Pearson challenged it. His method paired this flexible modeling with a goodness-of-fit procedure to judge how well a chosen distribution matched the data. It is broadly recognized as a pillar upon which much of modern statistics was built, transforming how scientists evaluate whether a theoretical model genuinely describes observed reality.
Mathematical Architecture and Asymptotic Behavior
The elegance of the chi-squared test lies in its mathematical structure. When n observations are partitioned into k mutually exclusive classes, and a null hypothesis assigns a probability p_i to each class, the expected count for class i becomes m_i = n·p_i. Pearson demonstrated that the quantity summing (x_i − m_i)² / m_i across all classes converges to a chi-squared distribution as n grows without bound. This asymptotic property is the test's defining characteristic: the shape of the statistic's sampling distribution draws nearer to the chi-squared curve as the number of observations grows, which is precisely why the test is recommended for large samples. The validity of the chi-squared distribution for the test statistic further requires that observations be independent. Beyond the classic goodness-of-fit setting, the same distributional logic extends to testing whether a pair of random variables is independent, based on paired observations. In both scenarios, the chi-squared framework provides a unified route to hypothesis testing that does not require the data to be normally distributed.
Practical Boundaries and the Role of Alternatives
The chi-squared test, while powerful, operates within clearly defined constraints that practitioners must respect. Its primary requirement is a sufficiently large sample size; the asymptotic convergence to the chi-squared distribution simply does not hold for small datasets. In such cases, Fisher's exact test serves as the appropriate alternative, computing exact probabilities rather than relying on distributional approximation. Additionally, the observations must fall into mutually exclusive classes—each data point belongs to one and only one category—and the independence of observations is a non-negotiable assumption for the test statistic to follow the chi-squared distribution. The test is also fundamentally a tool for categorical, not continuous, data, making it unsuitable for scenarios where the variables of interest are measured on a numerical scale. These boundaries do not diminish the test's utility but rather clarify its domain: large-sample, categorical, independence-based inference remains the territory where the chi-squared approach delivers its most reliable and interpretable results.
More in Probability And Stochastic Processes 1-21
Spotted an error? Know more?
This is a living reference — every entry is fact-audited, and reader corrections feed straight into our audit queue. Suggest an edit · See this site's audit record
