Hypothesis Testing Categorical Data Nonparametric 25 min read Updated August 19, 2026
BY: Statistics Fundamentals Team
Reviewed By: Minsa A (Senior Statistics Editor)

Chi-Square Test: Formula, Table & Step-by-Step Guide (With Examples)

A survey reports 60% of men prefer Brand A while only 35% of women do. Is that gap real or just sampling noise? A raw percentage comparison cannot answer that — the chi-square test can. With the formula χ² = Σ[(O − E)² / E], it tells you whether the difference between observed and expected counts is too large to ignore.

This guide covers the chi-square test formula in plain language, a complete critical values table with instructions on how to read it, an interactive calculator, eight worked steps you can apply to any dataset, SPSS and R code, Python code, three fully worked examples, and an effect size guide. Every section is designed for both exam preparation and active research use.

What You'll Learn
  • ✓ The chi-square test formula χ²=Σ[(O−E)²/E] with every variable explained
  • ✓ How to read the chi-square distribution table at α = 0.10, 0.05, 0.025, 0.01, 0.001
  • ✓ How to calculate chi-square step by step using an 8-stage method
  • ✓ Three worked examples: medicine, genetics, and market research
  • ✓ SPSS menu walkthrough, R code, and Python code for both test types
  • ✓ Effect size (Cramér's V) and APA 7th edition reporting format
  • ✓ Chi-square test of homogeneity — the third test type most guides skip
  • ✓ When chi-square fails — and which alternative test to use

What Is a Chi-Square Test?

Definition — Chi-Square Test (χ² Test)
A chi-square test is a nonparametric statistical test used to determine whether observed categorical data differ significantly from expected frequencies, or whether two categorical variables are independent of each other. It measures how much the data deviate from what chance alone would predict.
χ² = Σ [(O − E)² / E]

Chi-square tests work on count data — the number of people, items, or observations that fall into each category. They do not require the data to follow a normal distribution, which makes them one of the most broadly applicable tools in hypothesis testing. Researchers use chi-square tests in medical trials, ecology, marketing surveys, genetics, machine learning, and any field where outcomes are measured in categories rather than continuous numbers.

The test was developed by Karl Pearson in 1900. According to the NIST/SEMATECH Engineering Statistics Handbook, it is the standard approach for categorical data inference when expected cell counts are adequate. Understanding its assumptions before running the test is as important as the calculation itself — see the assumptions page for the broader picture.

⚡ Quick Reference — Chi-Square Key Facts
  • Formula: χ² = Σ[(O − E)² / E], where O = observed frequency, E = expected frequency
  • Data requirement: Categorical variables only (counts/frequencies, not means)
  • Three main types: Goodness-of-fit, test of independence, test of homogeneity
  • Key assumption: Every expected cell frequency must be ≥ 5
  • Most common critical value: df = 1, α = 0.05 → χ² = 3.841
  • Effect size: Use Cramér's V — V = √(χ² / [n × min(r−1, c−1)])
  • Small samples: When any E < 5, use Fisher's exact test instead
3.841
Critical value
df=1, α=0.05
≥ 5
Min. expected
cell frequency
1900
Year Pearson
developed it
χ²
Symbol (Greek
letter chi-squared)

Three Types of Chi-Square Tests

Chi-square tests take three distinct forms. Choosing the wrong one is a common mistake that invalidates your analysis, so it is worth being precise about what each one does.

Feature Goodness-of-Fit Test Test of Independence Test of Homogeneity
Number of variables1 categorical variable2 categorical variables1 variable across 2+ populations
Data structureSingle frequency tableContingency table (rows × columns)Separate samples from each population
Research questionDoes this variable follow a specified distribution?Are these two variables associated?Do multiple populations have the same distribution?
Null hypothesis (H₀)Observed = expected distributionThe two variables are independentAll populations have equal proportions
Expected frequencyE = n × p (theoretical proportion)E = (Row Total × Col Total) / NE = (Row Total × Col Total) / N (same formula)
Degrees of freedomk − 1(r − 1)(c − 1)(r − 1)(c − 1)
Classic exampleDo die faces appear equally often?Is gender associated with product preference?Do smoking rates differ across three cities?

Chi-Square Goodness-of-Fit Test

The goodness-of-fit test asks: does a single categorical variable match a theoretical distribution? You collect counts across k categories and compare them to expected counts under a specified null hypothesis. A genetics researcher testing whether a cross follows Mendel's 9:3:3:1 ratio, or a quality engineer testing whether defect types are uniformly distributed, both use this form. Degrees of freedom: df = k − 1.

Chi-Square Test of Independence

The test of independence asks: are two categorical variables related? Both variables are measured on the same sample. Their joint counts are arranged in a contingency table and the test determines whether the pattern is consistent with independence. This is the most common form in social science, medical, and marketing research. Degrees of freedom: df = (r − 1)(c − 1).

Chi-Square Test of Homogeneity

The test of homogeneity asks: do multiple independent populations have the same distribution of a categorical variable? Unlike the test of independence (one sample, two measured variables), homogeneity uses separate random samples from each population. The calculation is mechanically identical — same formula, same df formula — but the research design and interpretation differ. For example: "Do students in three different universities prefer the same study methods?" uses homogeneity; "Are gender and study method preference related in one sample?" uses independence.

Chi-Square Test Formula Explained

The Chi-Square Formula: χ² = Σ[(O − E)² / E]

Chi-Square Test Statistic — Pearson (1900)
χ² = Σ [(O − E)² / E]
Sum across all categories (goodness-of-fit) or all cells (test of independence)
χ² = chi-square test statistic O = observed frequency (actual count) E = expected frequency (under H₀) Σ = sum over all categories or cells

In plain terms: For every cell or category, subtract the expected count from the observed count, square the result (to eliminate negative values), divide by the expected count (to standardize for scale), then add all those values together. A larger χ² means the data deviate more from the null hypothesis. Because every term is squared, χ² is always ≥ 0 — it can never be negative.

How to Calculate Expected Frequencies

Expected Frequency — Goodness-of-Fit
E = n × p
n = total sample size, p = theoretical expected proportion for that category
Expected Frequency — Test of Independence / Homogeneity
E = (Row Total × Column Total) / Grand Total
Calculate for every cell individually using the marginal totals

Degrees of Freedom Formula

Degrees of Freedom (df)
Goodness-of-fit: df = k − 1
Independence / Homogeneity: df = (r − 1)(c − 1)
k = number of categories; r = rows; c = columns in the contingency table

The degrees of freedom determine which chi-square distribution to use when finding the p-value or critical value. Higher df shifts the distribution to the right — the same χ² value corresponds to a larger p-value when df is larger. This is why the critical value at df = 1 (3.841 at α = 0.05) is much smaller than the critical value at df = 9 (16.919 at α = 0.05). Understanding degrees of freedom is key to correctly applying this test.

Chi-Square Test Assumptions (Conditions)

Chi-square test results are only valid when these five conditions hold. Penn State's STAT 500 course lists adequate expected cell frequency as the most commonly violated assumption in practice (Penn State STAT 500, Lesson 8).

1
Categorical data

Both variables must be categorical — nominal (unordered labels like colors or countries) or ordinal (ordered categories like rating scales). Chi-square cannot be directly applied to continuous measurements. See types of data for the distinction.

2
Independent observations

Each subject or observation contributes to exactly one cell. Observations must not be paired, matched, or repeated. For paired categorical data, use McNemar's test instead.

3
Adequate expected frequencies (E ≥ 5 per cell)

Every expected cell frequency must be at least 5. If more than 20% of cells have E < 5, the chi-square approximation is unreliable. For 2×2 tables with small expected counts, use Fisher's exact test (see Fisher's exact test examples).

4
Random or representative sampling

Data must come from a random sample or a representative sampling design. Non-random convenience samples limit the generalizability of the result. See study design for sampling principles.

5
Mutually exclusive categories

Each observation must fall into one and only one category. Overlapping categories (where an observation could be counted in two cells) violate the independence assumption and invalidate the test.

⚠️
Most Violated Assumption

Expected frequencies below 5 account for the majority of chi-square misapplications in published research. Always check E values before reporting results. The SPSS output footnote and R's chisq.test()$expected both flag this automatically. When the violation occurs, Fisher's exact test is your primary alternative.

Chi-Square Distribution Table (Critical Values)

Use this table to find the critical value for your test. Locate your degrees of freedom (df) in the left column, find the column matching your significance level (α), and read the critical value at their intersection. If your calculated χ² exceeds the critical value, reject the null hypothesis.

How to Read the Chi-Square Table

📖 4-Step Guide — How to Read a Chi-Square Critical Value Table
  1. Calculate your degrees of freedom (df). For a test of independence or homogeneity: df = (rows − 1)(columns − 1). For goodness-of-fit: df = k − 1, where k is the number of categories. Find this number in the leftmost column of the table.
  2. Choose your significance level (α). The most common choice is α = 0.05 (5%). Identify the column header that matches your α level — the table below shows 0.10, 0.05, 0.025, 0.01, and 0.001.
  3. Read the critical value at the intersection. Where your df row meets your α column is your critical value. Example: df = 1 and α = 0.05 gives the critical value 3.841 (highlighted in the table below).
  4. Compare your test statistic to the critical value. If your calculated χ² is greater than the critical value → reject H₀ (statistically significant). If χ² is less than or equal to the critical value → fail to reject H₀.
df α = 0.10 α = 0.05 α = 0.025 α = 0.01 α = 0.001
12.7063.8415.0246.63510.828
24.6055.9917.3789.21013.816
36.2517.8159.34811.34516.266
47.7799.48811.14313.27718.467
59.23611.07012.83315.08620.515
610.64512.59214.44916.81222.458
712.01714.06716.01318.47524.322
813.36215.50717.53520.09026.125
914.68416.91919.02321.66627.877
1015.98718.30720.48323.20929.588
1218.54921.02623.33726.21732.910
1522.30724.99627.48830.57837.697
2028.41231.41034.17037.56645.315
2534.38237.65240.64644.31452.620
3040.25643.77346.97950.89259.703
4051.80555.75859.34263.69173.402
5063.16767.50571.42076.15486.661
6074.39779.08283.29888.37999.607
8096.578101.879106.629112.329124.839
100118.498124.342129.561135.807149.449

Highlighted: χ² = 3.841 at df = 1, α = 0.05 — the most commonly referenced critical value. Source: tabulated from the chi-square CDF. Values match the NIST/SEMATECH Statistics Handbook Table. For the extended downloadable version, visit the Chi-Square Table reference page or the how to read the chi-square table guide.

Quick Lookup — Common Scenarios

ScenariodfCritical value α = 0.05Critical value α = 0.01
2-category goodness-of-fit13.8416.635
3-category goodness-of-fit25.9919.210
4-category goodness-of-fit37.81511.345
2×2 contingency table13.8416.635
2×3 contingency table25.9919.210
3×3 contingency table49.48813.277
3×4 contingency table612.59216.812
4×4 contingency table916.91921.666
Mendel's 9:3:3:1 ratio (4 categories)37.81511.345

How to Calculate a Chi-Square Test: 8-Step Method

📋
Chi-Square Test — 8 Steps (Featured Snippet)

Step 1: State H₀ and H₁. Step 2: Set α. Step 3: Build the contingency table with observed counts. Step 4: Calculate expected frequencies using E = (Row × Col) / N. Step 5: Compute χ² = Σ[(O − E)² / E]. Step 6: Find df = (r−1)(c−1). Step 7: Look up the critical value in the chi-square table. Step 8: Compare χ² to the critical value and state the conclusion.

Worked Example — Full 8-Step Calculation

Research question: Is there a statistically significant association between gender (Male/Female) and brand preference (Brand A / Brand B) in a sample of 100 consumers?

1

State the hypotheses:
H₀: Gender and brand preference are independent (no association)
H₁: Gender and brand preference are associated

2

Set the significance level: α = 0.05

3

Build the observed contingency table:

Brand ABrand BRow Total
Male302050
Female104050
Col Total4060100
4

Calculate expected frequencies using E = (Row Total × Column Total) / Grand Total:

CellCalculationExpected (E)
Male / Brand A(50 × 40) / 10020.0
Male / Brand B(50 × 60) / 10030.0
Female / Brand A(50 × 40) / 10020.0
Female / Brand B(50 × 60) / 10030.0

✓ All expected frequencies ≥ 5. Assumption satisfied.

5

Calculate the chi-square statistic using χ² = Σ[(O − E)² / E]:

CellOE(O − E)²(O − E)² / E
Male / Brand A30201005.000
Male / Brand B20301003.333
Female / Brand A10201005.000
Female / Brand B40301003.333
Totalχ² = 16.667
6

Degrees of freedom: df = (r − 1)(c − 1) = (2 − 1)(2 − 1) = 1

7

Critical value: At df = 1 and α = 0.05 → from the chi-square table above: critical value = 3.841

8

Decision: χ² = 16.667 > critical value 3.841 → Reject H₀

✓ Conclusion: There is a statistically significant association between gender and brand preference (χ²(1, N = 100) = 16.67, p < .001). Men and women differ in their brand preferences beyond what chance alone would predict.

Chi-Square Calculator (Interactive)

🧮 Chi-Square Test of Independence Calculator

Enter observed counts for a 2×2 contingency table. The calculator computes χ², degrees of freedom, the p-value approximation, and Cramér's V effect size. For larger tables, use the full chi-square calculator.

Observed Counts (O)

📊
Enter counts in the 2×2 table to the left and click Calculate.

Chi-Square Test Examples (Three Fields)

Example 1 — Medical Research: Smoking and Lung Disease

Worked Example — Test of Independence (Medicine)

Research question: Is smoking status (Smoker / Non-Smoker) associated with lung disease diagnosis (Yes / No) in a sample of 300 patients?

1

Observed contingency table:

Lung Disease: YesLung Disease: NoRow Total
Smoker9060150
Non-Smoker30120150
Col Total120180300
2

Expected frequencies:
Smoker/Yes: (150 × 120) / 300 = 60  |  Smoker/No: (150 × 180) / 300 = 90
Non-Smoker/Yes: (150 × 120) / 300 = 60  |  Non-Smoker/No: (150 × 180) / 300 = 90

3

Chi-square statistic:
(90−60)²/60 + (60−90)²/90 + (30−60)²/60 + (120−90)²/90
= 900/60 + 900/90 + 900/60 + 900/90 = 15 + 10 + 15 + 10 = χ² = 50.00

4

df = 1. Critical value at α = 0.05, df = 1: 3.841. Since 50.00 ≫ 3.841, reject H₀.

✓ Conclusion: Smoking status and lung disease are significantly associated (χ²(1, N = 300) = 50.00, p < .001). Cramér's V = √(50/300) = 0.408 — a medium-to-large effect.

Example 2 — Genetics: Mendel's Goodness-of-Fit Test

Worked Example — Goodness-of-Fit (Biology / Genetics)

Research question: Does a dihybrid pea plant cross produce phenotype ratios consistent with Mendel's predicted 9:3:3:1 ratio in a sample of 160 offspring?

1

Observed vs. expected counts:

PhenotypeObserved (O)RatioExpected (E = n × p)(O−E)²/E
Round/Yellow909/1690.00.000
Round/Green283/1630.00.133
Wrinkled/Yellow323/1630.00.133
Wrinkled/Green101/1610.00.000
Total160160χ² = 0.267
2

df = k − 1 = 3. Critical value at α = 0.05, df = 3: 7.815. Since 0.267 ≪ 7.815, fail to reject H₀.

✓ Conclusion: The observed phenotype ratios are consistent with Mendel's 9:3:3:1 prediction (χ²(3, N = 160) = 0.27, p = .966).

Example 3 — Market Research: Chi-Square Test of Homogeneity

Worked Example — Test of Homogeneity (Market Research)

Research question: Do customers in three cities (London, Manchester, Leeds) have the same distribution of subscription tier preferences (Basic / Standard / Premium)?

1

Observed contingency table (separate samples from each city):

BasicStandardPremiumRow Total
London408030150
Manchester506040150
Leeds307050150
Col Total120210120450
2

Expected frequencies: E = (Row Total × Col Total) / Grand Total
Example: London/Basic: (150 × 120) / 450 = 40. London/Standard: (150 × 210) / 450 = 70. London/Premium: (150 × 120) / 450 = 40. (Repeat for each city.)

3

Chi-square calculation:
χ² = (40−40)²/40 + (80−70)²/70 + (30−40)²/40 + (50−40)²/40 + (60−70)²/70 + (40−40)²/40 + (30−40)²/40 + (70−70)²/70 + (50−40)²/40
= 0 + 1.429 + 2.500 + 2.500 + 1.429 + 0 + 2.500 + 0 + 2.500 = χ² = 12.857

4

df = (3−1)(3−1) = 4. Critical value at α = 0.05, df = 4: 9.488. Since 12.857 > 9.488, reject H₀.

✓ Conclusion: Subscription tier preferences differ significantly across the three cities (χ²(4, N = 450) = 12.86, p = .012). The three populations do not share the same distribution of subscription tiers. For more solved examples, see chi-square test examples.

How to Report Chi-Square Results (APA Format)

When writing up chi-square test results, follow the APA 7th edition format. This is required by most journals and expected in graduate-level coursework.

APA 7th Edition Reporting Format
χ²(df, N = sample size) = value, p = p-value, V = Cramér's V

Full sentence examples:

  • For independence: "A chi-square test of independence found a significant relationship between gender and brand preference, χ²(1, N = 100) = 16.67, p < .001, Cramér's V = 0.41."
  • For goodness-of-fit: "A chi-square goodness-of-fit test indicated the observed phenotype distribution was consistent with the 9:3:3:1 Mendelian ratio, χ²(3, N = 160) = 0.27, p = .97."
  • For homogeneity: "A chi-square test of homogeneity revealed significant differences in subscription tier preferences across the three cities, χ²(4, N = 450) = 12.86, p = .012, Cramér's V = 0.17."
Always report effect size

Statistical significance alone does not tell the reader how large the association is. With large samples, a trivially small association can produce p < .001. Always accompany a significant chi-square result with Cramér's V (or Phi for 2×2 tables). See the effect size guide for full details.

Effect Size: Cramér's V and Phi (φ)

A significant chi-square result tells you the association is real; Cramér's V tells you how strong it is. Cohen (1988) established the benchmark thresholds below, though Lakens (2013) notes they should be treated as contextual guides rather than rigid rules.

Cramér's V — Effect Size for Chi-Square
V = √( χ² / [n × min(r − 1, c − 1)] )
n = total sample size, r = rows, c = columns. V ranges from 0 (no association) to 1 (perfect association).
Cramér's VEffect Sizedf = 1 (2×2)df = 2 (2×3)df = 3 (2×4)
0.10SmallWeak associationWeak associationWeak association
0.30MediumModerate associationModerate associationModerate association
0.50LargeStrong associationStrong associationStrong association

For 2×2 tables specifically, Phi (φ) is equivalent to Cramér's V: φ = √(χ²/n). Both yield the same value when df = 1. Use the effect size calculator to compute Cramér's V automatically.

Chi-Square Test in SPSS

Test of Independence in SPSS (Step by Step)

SPSS — Step-by-Step Menu Navigation

Running a chi-square test of independence in IBM SPSS Statistics

1

Go to Analyze → Descriptive Statistics → Crosstabs

2

Move your first variable into the Row(s) box and your second variable into the Column(s) box

3

Click Statistics → check Chi-square → also check Phi and Cramer's V for effect size → click Continue

4

Click Cells → check Observed and Expected under Counts → check Row under Percentages → click Continue → OK

Reading SPSS output: In the Chi-Square Tests table, read the Pearson Chi-Square row. The Asymptotic Significance (2-sided) column is your p-value. Check the footnote for "X cells have expected count less than 5" — if this appears, consider Fisher's Exact Test (also reported in the same table). The Symmetric Measures table gives Cramér's V.

Goodness-of-Fit in SPSS

Navigate to Analyze → Nonparametric Tests → Legacy Dialogs → Chi-Square. Move your variable into the Test Variable List. Under Expected Values, choose "All categories equal" for a uniform distribution, or enter custom expected proportions. Click OK.

Chi-Square Test in R

Test of Independence in R

R
# Create the observed contingency table data_matrix <- matrix(c(30, 20, 10, 40), nrow = 2, dimnames = list( Gender = c("Male", "Female"), Preference = c("Brand A", "Brand B") )) # Run the chi-square test result <- chisq.test(data_matrix, correct = FALSE) # correct=FALSE matches hand calc print(result) # X-squared = 16.667, df = 1, p-value = 4.46e-05 # Verify expected frequencies (must all be ≥ 5) result$expected # Calculate Cramér's V effect size library(rstatix) cramer_v(data_matrix)

Goodness-of-Fit in R

R
# Observed phenotype counts (Mendel's cross) observed <- c(90, 28, 32, 10) # Expected proportions from Mendel's 9:3:3:1 ratio expected_probs <- c(9/16, 3/16, 3/16, 1/16) # Run the goodness-of-fit test chisq.test(observed, p = expected_probs) # X-squared = 0.267, df = 3, p-value = 0.966
⚠️
Yates' Continuity Correction

R applies Yates' correction by default for 2×2 tables (subtract 0.5 before squaring), which reduces the χ² slightly. To match hand calculations, use chisq.test(data, correct = FALSE). For small samples where any E < 5, use fisher.test() instead.

Chi-Square Test in Python

Test of Independence Using SciPy

Python
from scipy.stats import chi2_contingency import numpy as np # Observed contingency table (rows=Gender, cols=Preference) observed = np.array([[30, 20], # Male: Brand A, Brand B [10, 40]]) # Female: Brand A, Brand B # Run the chi-square test (correction=False to match hand calculation) chi2, p_value, df, expected = chi2_contingency(observed, correction=False) print(f"Chi-square statistic: {chi2:.4f}") # 16.6667 print(f"p-value: {p_value:.6f}") # 0.000045 print(f"Degrees of freedom: {df}") # 1 print(f"Expected frequencies:\n{expected}") # Calculate Cramér's V manually n = observed.sum() cramers_v = np.sqrt(chi2 / (n * min(observed.shape[0]-1, observed.shape[1]-1))) print(f"Cramér's V: {cramers_v:.4f}") # 0.4082

Goodness-of-Fit in Python

Python
from scipy.stats import chisquare # Observed and expected counts (Mendel's cross) observed = [90, 28, 32, 10] expected = [90.0, 30.0, 30.0, 10.0] # n × p for 9:3:3:1 ratio, n=160 chi2, p_value = chisquare(f_obs=observed, f_exp=expected) print(f"Chi-square: {chi2:.4f}") # 0.2667 print(f"p-value: {p_value:.4f}") # 0.9659 # Interpretation: data consistent with 9:3:3:1 ratio

Chi-Square vs. Other Statistical Tests

Chi-Square vs. t-Test

The choice between a chi-square test and a t-test comes down to the type of outcome variable. For a full comparison, see the dedicated chi-square vs. t-test guide.

FeatureChi-Square Testt-Test
Outcome variable typeCategorical (counts)Continuous (means)
Normality requiredNoYes (or large n)
What it testsAssociation or distributionDifference between means
Example question"Is political party related to voting behavior?""Is the mean exam score higher in Group A vs B?"
Effect sizeCramér's VCohen's d

Chi-Square vs. Fisher's Exact Test

FeatureChi-Square TestFisher's Exact Test
Best forLarge samples (all E ≥ 5)Small samples (any E < 5)
CalculationApproximate (asymptotic)Exact probability
Table sizeAny r × cMost commonly 2×2
Sample size guidancen > 40 (with all E ≥ 5)n < 20, or any E < 5
SoftwareDefault in SPSS, R, PythonCheckbox in SPSS; fisher.test() in R; scipy.stats.fisher_exact() in Python

Chi-Square vs. ANOVA

FeatureChi-Square TestANOVA
Outcome variableCategorical (counts)Continuous (means)
Independent variableCategorical groupsCategorical groups
TestsAssociation between categoriesDifferences in group means
Effect sizeCramér's Vη² (eta squared)

For a structured decision guide covering all major statistical tests, see the Statistical Test Selector tool, or the broader parametric vs. nonparametric tests guide.

Where Chi-Square Tests Are Used

🏥

Medical Research

Testing whether treatment outcomes (recovered/not recovered) differ by treatment group. Routine in randomized controlled trials with binary endpoints. See hypothesis testing in clinical trials.

🧬

Genetics & Biology

Verifying whether observed genotype or phenotype ratios match Mendelian or Hardy-Weinberg predictions in population genetics studies.

📊

Survey Analysis

Determining whether survey responses differ by demographic groups such as age, gender, or education level. Standard in social science research.

🛒

Market Research

Testing whether brand preferences, product choices, or consumer behaviors differ across customer segments or regions. See customer segmentation statistics.

🤖

Machine Learning

Feature selection: identifying which categorical features are statistically associated with the target variable before model training. See statistics for machine learning.

🔬

A/B Testing

Comparing conversion rates, click-through rates, or other binary outcomes between two variants. See how statistics powers A/B testing.

🌿

Ecology

Comparing species distribution across habitat types, or testing whether species are associated with particular environmental conditions.

🏭

Quality Control

Testing whether defect rates or product categories are uniformly distributed across production lines, batches, or suppliers.

When Chi-Square Fails: Alternative Tests

Problem / ConditionRecommended AlternativeWhy
Expected frequencies < 5 in any cell (small sample)Fisher's exact testExact computation; no large-sample approximation
Paired or matched categorical dataMcNemar's testAccounts for non-independence of matched pairs
Ordered categories (ordinal data)Cochran-Armitage trend testDetects monotonic trend rather than general association
Very large N (χ² inflated trivially)Report Cramér's V; interpret practicallyWith huge n, even negligible associations become significant
Three or more repeated measuresCochran's Q testExtension of McNemar for k > 2 related groups
Three or more independent groupsKruskal-Wallis test (if ordinal)Nonparametric test for comparing k ≥ 3 groups on ordinal outcomes

Frequently Asked Questions

Chi-Square Test Cheat Sheet (Quick Reference)

Every key term, formula, and decision rule from this guide in one structured table.

Term / Entity Formula / Value When to Use Interpretation
Chi-square statistic (χ²)χ² = Σ[(O − E)² / E]All chi-square testsTotal deviation of observed from expected counts
Expected freq — goodness-of-fitE = n × pSingle-variable testCount predicted by theoretical proportion p
Expected freq — independenceE = (Row × Col) / NTwo-variable testCount predicted if variables were unrelated
df — goodness-of-fitdf = k − 1k = number of categoriesNumber of free cells after constraints applied
df — independence / homogeneitydf = (r−1)(c−1)r × c contingency tableSame logic; both row and column margins constrained
Critical value (df=1, α=0.05)3.841Most 2×2 tablesExceed this → reject H₀ at 5% level
Critical value (df=1, α=0.01)6.6352×2 with stricter thresholdExceed this → reject H₀ at 1% level
Cramér's VV = √(χ²/[n × min(r−1,c−1)])After significant χ²0.10=small, 0.30=medium, 0.50=large
Phi (φ) — 2×2 tables onlyφ = √(χ²/n)2×2 contingency tableEquivalent to Cramér's V when df = 1
p-value interpretationP(χ² ≥ observed | H₀ true)Always reportp < 0.05 → reject H₀ (at conventional α)
Assumption: expected frequencyE ≥ 5 per cellEvery chi-square testIf violated, use Fisher's exact test instead
APA reporting formatχ²(df, N = n) = value, p = .xxxAll publicationsInclude df, sample size, statistic, p-value, V
Small sample alternativeFisher's exact testAny E < 5Exact p-value; no approximation needed
Paired data alternativeMcNemar's testBefore/after or matched pairsSame χ² statistic but accounts for dependency

Continue Learning at Statistics Fundamentals

Related Topics in Hypothesis Testing & Statistics

Chi-square tests connect to a network of statistical concepts. The guides below cover prerequisite ideas and follow-on methods in natural learning sequence.

External References & Authority Sources