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
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
| Category | O | E | (O − E)² / E |
|---|---|---|---|
| 1 | 742 | 736 | 0.04891 |
| 2 | 388 | 384 | 0.04167 |
| 3 | 271 | 288 | 1.0035 |
| 4 | 199 | 192 | 0.2552 |
The worked steps
The total count
n = 742 + 388 + 271 + 199 = 1600Expected counts
E = n × share = 736, 384, 288, 192Each category's contribution
(O − E)² / E = 0.04891 + 0.04167 + 1.0035 + 0.2552The χ² statistic
χ² = 1.3493Degrees of freedom
df = k − 1 − ddof = 4 − 1 − 0 = 3The p-value
p = P(χ² ≥ 1.3493) = 0.7175Critical value at α
α = 0.05: χ²* = 7.8147The smallest expected count
min E = 192Effect 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)
Formulas
Each category adds its squared miss, scaled by what was expected; df counts the categories that are free to vary.
Try this
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.
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.
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.