INFERENTIALInference & TestsStatistics Calculator
📊

Chi-Square — Goodness of Fit & Independence

χ² = Σ(O-E)²/E. Test if observed matches expected. Goodness-of-fit: one variable. Independence: two-way table. Cramér's V for effect size.

Concept Fundamentals
Σ(O−E)²/E
χ² Test
Pearson's chi-square
(r−1)(c−1)
Degrees of Freedom
Contingency table
No association
Null Hypothesis
Independence test
Karl Pearson 1900
Developer
Goodness of fit
Run Chi-Square TestGoodness-of-fit or independence

Why This Statistical Analysis Matters

Why: Chi-square tests categorical associations. Dice fairness, genetics, surveys, A/B tests. When expected < 5, consider Fisher's exact.

How: Goodness-of-fit: enter observed and expected (or equal). Independence: enter contingency table. Get χ², p-value, df, Cramér's V.

  • χ² = Σ(O-E)²/E
  • Cramér's V effect size
  • df = (r-1)(c-1) for independence
χ²
STATISTICSInference & Tests

Chi-Square Tests — Categorical Data Analysis

Goodness-of-fit and test of independence. χ² statistic, p-value, Cramér's V, residuals. Dice fairness, genetics, surveys, quality control.

Real-World Scenarios — Click to Load

Goodness-of-Fit Data

chi_square_results.sh
CALCULATED
$ chi_square --mode="goodness" --alpha=0.05
Decision
FAIL TO REJECT
χ² statistic
1.1429
df
5
p-value
0.8756
Share:
Chi-Square Test Result
Goodness-of-fit (k=6, n=70)
χ² = 1.143
df = 5p = 0.8756Not significant
numbervibe.com/calculators/statistics/chi-square-calculator

Chi-Square Distribution (df=5) — Rejection Region & p-value

Observed vs Expected

Calculation Breakdown

OBSERVED/EXPECTED
Observed frequencies
10, 12, 14, 11, 13, 10
Expected frequencies
11.67, 11.67, 11.67, 11.67, 11.67, 11.67
Eᵢ = ext{total}/k ( ext{equal}) ext{or} ext{specified}
CHI-SQUARE COMPUTATION
Total count (n)
70
χ² contributions
(O1−E1)²/E1 = 0.2381 + (O2−E2)²/E2 = 0.0095 + (O3−E3)²/E3 = 0.4667 + (O4−E4)²/E4 = 0.0381 + (O5−E5)²/E5 = 0.1524 + (O6−E6)²/E6 = 0.2381
χ^{2} = \text{Sigma} (Oᵢ - Eᵢ)^{2}/Eᵢ
χ² statistic
1.1429
DECISION
Degrees of freedom
5
ext{df} = k - 1
p-value
0.8756
1 - ext{CDF}(χ^{2}, ext{df})
DECISION
Fail to reject H₀ at α=0.05 — distribution fits

For educational and informational purposes only. Verify with a qualified professional.

📈 Statistical Insights

χ²

χ² = Σ(O-E)²/E

— Pearson 1900

V

Cramér's V: effect size

— Independence

df

df = (r-1)(c-1)

— Independence

Key Takeaways

  • • χ² = Σ(O − E)²/E — measures discrepancy between observed and expected frequencies
  • • Goodness of fit: df = k − 1. Independence: df = (r−1)(c−1)
  • • Assumption: each expected frequency ≥ 5. If not, combine categories or use Fisher's exact for 2×2
  • • Yates correction: for 2×2 tables with small counts, use |O−E|−0.5 before squaring
  • • Cramér's V: effect size for independence. V < 0.1 negligible, 0.1–0.3 small–medium, > 0.3 large

Did You Know?

📐Karl Pearson introduced the chi-square test in 1900 for goodness of fit in his Philosophical Magazine paper.Source: Pearson 1900
🗳️Exit polls use chi-square to test if voting patterns differ by demographic group.Source: Election research
🧬Hardy-Weinberg equilibrium in genetics is tested with chi-square goodness of fit.Source: Population genetics
📧Spam filters can use chi-square to test if word frequencies differ between spam and ham.Source: NLP
🩺For 2×2 tables with expected &lt; 5, Fisher's exact test is preferred over chi-square.Source: Agresti
📊Cramér's V is named after Harald Cramér (1946) — it standardizes chi-square by sample size.Source: MathWorld

How Chi-Square Tests Work

1. Goodness of Fit

H₀: data follow a specified distribution. χ² = Σ(Oᵢ − Eᵢ)²/Eᵢ. df = k − 1.

2. Test of Independence

H₀: two categorical variables are independent. Eᵢⱼ = (row total × col total) / grand total. df = (r−1)(c−1).

3. P-value

p = 1 − CDF(χ², df) from the chi-square distribution. Reject H₀ if p < α.

4. Cramér's V

V = √(χ²/(n×min(r−1,c−1))). Effect size: 0.1 small, 0.3 medium, 0.5 large.

5. Yates correction

For 2×2 tables with small expected counts, use (|O−E|−0.5)²/E to reduce Type I error.

Expert Tips

Expected ≥ 5

If any E < 5, combine categories or use Fisher's exact test for 2×2.

Yates for 2×2

Use Yates correction when expected counts are small (e.g., 5–10).

Report effect size

Always report Cramér's V with the chi-square test of independence.

Fisher's exact

For 2×2 with small n, Fisher's exact test is more appropriate than chi-square.

Why Use This Calculator vs Other Tools?

FeatureThis CalculatorExcelR chisq.testSPSS
Goodness of fit + Independence⚠️ Manual
Cramér's V⚠️ Package
Expected table + residuals⚠️ Manual
Yates correction
Observed vs Expected chart
Chi-square distribution viz
No installation

Frequently Asked Questions

When should I use Yates correction?

For 2×2 contingency tables when expected frequencies are between 5 and 10. For expected < 5, use Fisher's exact test instead.

What if my expected frequencies are less than 5?

Combine categories to increase expected counts, or use Fisher's exact test for 2×2 tables. The chi-square approximation breaks down when E < 5.

What is Cramér's V and how do I interpret it?

Cramér's V is an effect size for the chi-square test of independence. V < 0.1 = negligible, 0.1–0.3 = small to medium, 0.3–0.5 = medium to large, > 0.5 = large.

What is the difference between goodness of fit and test of independence?

Goodness of fit: one variable, test if it follows a specified distribution. Independence: two variables, test if they are associated.

When should I use Fisher's exact test?

For 2×2 tables when expected cell counts are small (< 5). Fisher's exact computes the exact probability rather than relying on the chi-square approximation.

Chi-Square by the Numbers

E ≥ 5
Rule of thumb
1900
Pearson introduced χ²
V < 0.3
Small–medium effect
2×2
Yates correction

Disclaimer: This calculator uses the regularized incomplete gamma function for the chi-square CDF. Results are accurate for typical use. When expected frequencies are < 5, consider Fisher's exact test for 2×2 tables. Verify critical applications with established statistical software.

👈 START HERE
⬅️Jump in and explore the concept!
AI

Related Calculators