Explore

Chi-square tests: goodness of fit and independence

H₀: the counts follow the expected mix · H₁: they do not

χ² = 1.3493 · df = 3 · p = 0.7175

p = 0.7175 > α = 0.05: H₀ is not rejected. The counts fit the expected mix within chance (χ² = 1.3493). Failing to reject is not proof that the mix is exactly as expected.

How to read the picture

  • The curve is the null world: how χ² would vary if the counts only wobbled around the expected ones.

  • The vertical line is your χ²: the sum of every cell's (O − E)²/E.

  • The shaded tail is the p-value; χ² tests look only at the upper tail, since any departure makes χ² larger.

  • The tables below show where the departure lives: the contributions, or the residuals (O − E)/√E.

Your data

Test

Observed counts
One count per category, separated by commas.
Expected mix
Shares or counts in the same order; they are scaled to the observed total.
Parameters estimated from the data (ddof)

Significance level α

A chi-square test compares counts with the counts a hypothesis expects. For goodness of fit, the expected counts come from a planned mix; for independence, from the table's own margins. Each cell adds (O − E)²/E to χ², and the total lands on the chi-square curve. Type counts, never percentages.

The estimate and what the data show

Observed, expected and each category's contribution
CategoryOE(O − E)² / E
17427360.04891
23883840.04167
32712881.0035
41991920.2552

The worked steps

  1. The total count

    n = 742 + 388 + 271 + 199 = 1600
  2. Expected counts

    E = n × share = 736, 384, 288, 192
  3. Each category's contribution

    (O − E)² / E = 0.04891 + 0.04167 + 1.0035 + 0.2552
  4. The χ² statistic

    χ² = 1.3493
  5. Degrees of freedom

    df = k − 1 − ddof = 4 − 1 − 0 = 3
  6. The p-value

    p = P(χ² ≥ 1.3493) = 0.7175
  7. Critical value at α

    α = 0.05: χ²* = 7.8147
  8. The smallest expected count

    min E = 192
  9. Effect size (Cohen's w)

    w = √(χ² / n) = 0.02904

The same in code

scipy
from scipy import stats

stats.chisquare(f_obs=[742, 388, 271, 199], f_exp=[736, 384, 288, 192], ddof=0)
Excel
=CHISQ.TEST(A2:A5, B2:B5)
=CHISQ.DIST.RT(1.3493, 3)
Excel's CHISQ.TEST works out df itself as k − 1, which is wrong when a parameter was estimated from the data (ddof > 0); CHISQ.DIST.RT with your own df is then the way.

Formulas

Each category adds its squared miss, scaled by what was expected; df counts the categories that are free to vary.

Try this

  1. Counts, never percentages

    Open the contact mix and double every observed count (1484, 776, 542, 398).

    Look for: The shares stay the same, but χ² doubles and the p-value falls: χ² depends on how many were counted, which is why it must be given counts, not percentages.

  2. Yates on and off

    Open Helion H1 as a 2 × 2 table and switch Yates' correction off.

    Look for: Without the correction, χ² equals z² from the two-proportion test (4.095² = 16.77), and the p-values agree. Yates shrinks each |O − E| by a half, which matters only for small counts.

  3. Where the dependence lives

    Open segment × payment method and read the residuals table.

    Look for: The largest residual, Corporate × bank transfer, says corporate customers pay by transfer far more than independence predicts. χ² says there is dependence; the residuals say where.

An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to Hypothesis Testing Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.