acalculator

What is my chi-square test result?

Enter observed counts, with expected counts or a contingency table, to get the chi-square statistic, its p-value, and the decision at your significance level.

Your numbers

Test
Read as: 15; 12; 9; 9; 15
Common values: 0.10, 0.05, 0.01.
Chi-square statistic (χ²)
3

χ² = 3 with 4 degrees of freedom and a p-value of 0.557825. Do not reject the null hypothesis at α = 0.05.

Degrees of freedom
4
P-value
0.557825
Critical value
9.487729
Decision
Do not reject the null hypothesis
Expected counts below 5
0
Total count
60

Chi-square statistic (χ²): 3. χ² = 3 with 4 degrees of freedom and a p-value of 0.557825. Do not reject the null hypothesis at α = 0.05.

Where does your statistic fall?

How to calculate

Computes the chi-square statistic, degrees of freedom, and p-value of a goodness-of-fit test or a test of independence on a contingency table.

Example with the default inputs (Test Goodness of fit, Observed counts [15, 12, 9, 9, 15], Significance level (α) 0.05): χ² = 3 with 4 degrees of freedom and a p-value of 0.557825. Do not reject the null hypothesis at α = 0.05.

Method: χ² = Σ (O − E)² ÷ E; goodness of fit: E from the expected values scaled to the observed total, df = categories − 1; independence: E = row total × column total ÷ grand total, df = (rows − 1)(columns − 1); p-value = P(χ² with df degrees of freedom ≥ χ²).

  • The observations are independent counts. The chi-square p-value is an approximation that works best when every expected count is 5 or more.
  • The statistic is exact on the counts you type, then rounded once; the p-value is the chi-square upper tail, computed directly.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Test Goodness of fit, Observed counts 15, 12, 9, 9, 15, Significance level (α) 0.05 gives Chi-square statistic (χ²) 3, Degrees of freedom 4, P-value 0.557825, Decision Do not reject the null hypothesis, Total count 60.Source: OpenStax, Introductory Statistics 2e, §11.2 Goodness-of-Fit Test. https://openstax.org/books/introductory-statistics-2e/pages/11-2-goodness-of-fit-test, Example 11.2 (χ² = 3, df = 4, p-value 0.5578)
  2. Test Independence, Observed counts table 111, 96, 48; 96, 133, 61; 91, 150, 53, Significance level (α) 0.05 gives Chi-square statistic (χ²) 12.990919, Degrees of freedom 4, P-value 0.01132, Decision Reject the null hypothesis.Source: OpenStax, Introductory Statistics 2e, §11.3 Test of Independence. https://openstax.org/books/introductory-statistics-2e/pages/11-3-test-of-independence, Example 11.6 (χ² = 12.99, df = 4, p-value 0.0113)
  3. Test Goodness of fit, Observed counts 30, 14, 34, 45, 57, 20, Expected counts or proportions 20, 20, 30, 40, 60, 30, Significance level (α) 0.05 gives Chi-square statistic (χ²) 11.441667, Degrees of freedom 5, Critical value 11.070498, P-value 0.043293.Source: NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.15 Chi-Square Goodness-of-Fit Test. https://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm
  4. Test Goodness of fit, Observed counts 15, 12, 9, 9, 15, Expected counts or proportions 0.2, 0.2, 0.2, 0.2, 0.2, Significance level (α) 0.05 gives Chi-square statistic (χ²) 3, P-value 0.557825.Source: OpenStax, Introductory Statistics 2e, §11.2 Goodness-of-Fit Test. https://openstax.org/books/introductory-statistics-2e/pages/11-2-goodness-of-fit-test

How it works

Both tests use the Pearson chi-square statistic, χ² = Σ (O − E)² ÷ E, summed over every category or cell, where O is an observed count and E the expected count.

Goodness of fit

  • Enter k observed counts O₁ … Oₖ (2 to 100), and optionally k expected values e₁ … eₖ in the same order.
  • The expected values are scaled to the observed total N = ΣO: Eᵢ = eᵢ × N ÷ Σe. So counts, proportions, and percents all work. With no expected values, every Eᵢ = N ÷ k (equal counts).
  • Degrees of freedom: df = k − 1.

Independence

  • Enter a table of counts with r rows and c columns (2 to 10 each).
  • The expected count in row i, column j is Eᵢⱼ = (row i total) × (column j total) ÷ (grand total).
  • Degrees of freedom: df = (r − 1) × (c − 1).

Results

  • χ², the statistic above.
  • P-value = P(χ² with df degrees of freedom ≥ χ²), the upper tail of the chi-square distribution with df degrees of freedom.
  • Critical value: the value whose upper tail is α.
  • Decision: "Reject the null hypothesis" when the p-value is α or less, otherwise "Do not reject the null hypothesis".
  • Expected counts below 5: how many E values are below 5.
  • Total count: N.

Rules

  • Observed counts and table cells cannot be negative. The observed counts must add up to more than 0, and in a table every row and every column must have a total above 0.
  • For goodness of fit with expected values, there must be one expected value for each observed count, and every expected value must be above 0.
  • The significance level α is from 0.0000000001 to 0.5.
  • χ² is exact on the counts as typed (each E is an exact fraction), then rounded once to the nearest 64-bit float. The p-value comes from the chi-square upper tail, computed directly rather than as 1 minus the lower tail, so small p-values keep their precision.
  • Results show up to 6 decimal places (6 significant digits below 0.0001), with halves rounded up.

Worked examples by hand

Absences by weekday (OpenStax Example 11.2). Observed 15, 12, 9, 9, 15; total 60; expected 60 ÷ 5 = 12 each. χ² = (3² + 0² + 3² + 3² + 3²) ÷ 12 = 36 ÷ 12 = 3, df = 4. With 4 degrees of freedom the upper tail is e^(−x/2) × (1 + x/2) = e^(−1.5) × 2.5 = 0.557825, so at α = 0.05: Do not reject the null hypothesis. Entering the expected values as 0.2 each scales them to 12 and gives the same result.

Volunteer hours (OpenStax Example 11.6). Rows: community college 111, 96, 48; four-year college 96, 133, 61; nonstudents 91, 150, 53. Row totals 255, 290, 294; column totals 298, 379, 162; grand total 839. The first expected count is 255 × 298 ÷ 839 = 90.572. Adding all nine (O − E)² ÷ E gives χ² = 12.990919, df = (3 − 1)(3 − 1) = 4, p-value = e^(−6.4955) × 7.4955 = 0.01132: Reject the null hypothesis at α = 0.05.

Given expected counts. Observed 30, 14, 34, 45, 57, 20 against expected 20, 20, 30, 40, 60, 30 (both add up to 200, so no scaling). χ² = 100 ÷ 20 + 36 ÷ 20 + 16 ÷ 30 + 25 ÷ 40 + 9 ÷ 60 + 100 ÷ 30 = 5 + 1.8 + 0.533333 + 0.625 + 0.15 + 3.333333 = 11.441667, df = 5. The critical value at α = 0.05 is 11.070498, and the p-value is 0.043293.

Other questions people ask

What does a chi-square test tell me?

It measures how far observed counts are from the counts you would expect if the null hypothesis were true. A large χ² with a small p-value means the difference is bigger than chance usually produces.

When do I use goodness of fit and when independence?

Use goodness of fit for one variable, when you want to know whether its counts follow a stated pattern, such as equal absences on each weekday. Use independence for two variables in a table, such as volunteer type and hours, when you want to know whether they are related.

How do I calculate the chi-square statistic?

For each category or cell, subtract the expected count from the observed count, square it, and divide by the expected count; then add these up: χ² = Σ (O − E)² ÷ E. With observed 15, 12, 9, 9, 15 and 12 expected in each, χ² = (9 + 0 + 9 + 9 + 9) ÷ 12 = 3.

How are the expected counts found in a test of independence?

Each expected count is its row total times its column total, divided by the grand total. This is the count you would expect in that cell if the rows and columns were unrelated.

How many degrees of freedom does the test have?

Goodness of fit: the number of categories minus 1. Independence: (rows − 1) × (columns − 1). A 3 × 3 table has 4 degrees of freedom.

What if some expected counts are below 5?

The chi-square p-value is an approximation that is only reliable when expected counts are not too small; a common rule is that every expected count should be 5 or more. The calculator shows how many are below 5. Combining small categories, or an exact test, is safer then.

Can I enter percentages as expected values?

Yes. Expected values are scaled so they add up to the observed total, so counts, proportions (0.2), and percents (20) all work.