Statistics & Analysis

Chi Square Test

Definition

The chi square test is a statistical test that evaluates whether the distribution of observed frequencies across categories differs significantly from the frequencies that would be expected under a specified hypothesis, most commonly the hypothesis of independence between two categorical variables. It is one of the most widely used non parametric tests in research.

Why it matters

Categorical data are pervasive in clinical, social, and behavioral research, and the chi square test is the standard method for analyzing associations between categorical variables. It is used to test whether treatment response rates differ between groups, whether the distribution of demographic characteristics differs across study arms, whether the prevalence of a condition differs between exposed and unexposed populations, and whether observed genetic frequencies match expected proportions. Its simplicity, broad applicability, and minimal distributional assumptions make it accessible to researchers across disciplines, and it appears in the methods section of countless published studies.

How it works

The chi square test of independence, the most common variant, begins with a contingency table (also called a cross tabulation) that displays the frequency of observations for each combination of two categorical variables. The test compares the observed frequencies in each cell with the expected frequencies that would be observed if the two variables were independent.

Expected frequencies are calculated for each cell using the formula: (row total times column total) divided by the grand total. The chi square statistic is calculated as the sum, across all cells, of (observed frequency minus expected frequency) squared divided by the expected frequency. If the two variables are independent, this statistic follows an approximate chi square distribution with degrees of freedom equal to (number of rows minus 1) times (number of columns minus 1).

A large chi square statistic, corresponding to a small p value, indicates that the observed frequencies deviate substantially from the expected frequencies under independence, suggesting that the two variables are associated. The test does not indicate the strength or direction of the association; additional measures such as the odds ratio, relative risk, or Cramér's V are needed for that purpose.

The chi square goodness of fit test is a related variant that compares observed frequencies in a single categorical variable against expected frequencies specified by a theoretical distribution. It is used, for example, to test whether observed genotype frequencies match Hardy Weinberg equilibrium expectations.

The chi square test requires that expected cell counts be sufficiently large, with the conventional rule that no more than 20% of expected counts should be below 5 and none should be below 1. When these conditions are not met, Fisher's exact test provides a valid alternative for 2 by 2 tables, and exact tests or simulation based approaches are available for larger tables.

When to use it

Use the chi square test of independence when analyzing the association between two categorical variables, each with two or more categories, in a sample large enough to satisfy the expected frequency requirements. Use the goodness of fit variant when comparing observed frequencies of a single variable against a theoretical distribution. The chi square test is not appropriate for continuous data, for paired or matched designs (use McNemar's test instead), or for very small samples where expected counts are too low.

Key takeaways

  • Categorical data are pervasive in clinical, social, and behavioral research, and the chi square test is the standard method for analyzing associations between categorical variables.
  • The test compares the observed frequencies in each cell with the expected frequencies that would be observed if the two variables were independent.
  • Use the chi square test of independence when analyzing the association between two categorical variables, each with two or more categories, in a sample large enough to satisfy the expected frequency requirements.
  • A common error is applying the chi square test to data with small expected cell counts, producing an unreliable test statistic and p value.

Common mistakes

A common error is applying the chi square test to data with small expected cell counts, producing an unreliable test statistic and p value. Researchers should always check expected frequencies before interpreting the results and switch to Fisher's exact test or combine categories when necessary.

Another mistake is interpreting a significant chi square result as evidence of a strong association. A statistically significant chi square merely indicates that differences this large between observed and expected frequencies would be unlikely if the two variables were independent; the strength of the association must be assessed separately using measures like the odds ratio or Cramér's V. With very large samples, even trivially small associations can produce highly significant chi square statistics. Researchers should also report the direction of the association (which categories are over or under represented) rather than simply noting significance. Finally, applying the chi square test to paired or repeated measures data, which violate the independence assumption, is a common but serious error.

Example

A public health study examines whether vaccination status (vaccinated vs. unvaccinated) is associated with influenza infection during a flu season in a sample of 1,200 adults. The contingency table shows that 38 of 700 vaccinated adults (5.4%) and 54 of 500 unvaccinated adults (10.8%) developed confirmed influenza. The Pearson chi square statistic, without continuity correction, is 11.9 (df = 1, p < 0.001), indicating a statistically significant association between vaccination and influenza risk. The relative risk is 0.50 (95% CI: 0.34 to 0.75), meaning vaccinated adults had half the risk of infection compared to unvaccinated adults.

Sources

  1. [1]Field A. Discovering Statistics Using IBM SPSS Statistics. 6th ed. SAGE Publications, 2024.
  2. [2]Cochran WG. Some methods for strengthening the common χ² tests. Biometrics. 1954;10(4):417-451.
  3. [3]Agresti A. Categorical Data Analysis. 3rd ed. Wiley, 2013.

Cite this term

FullChi Square Test. Paperguide Research Glossary. Paperguide, 2026. Available at: https://paperguide.ai/research-glossary/chi-square-test/
In-text(Paperguide, 2026)

Related terms