Chi-Square Goodness of Fit and Large-Sample Tests
CSIR NET statistics: z-tests for means, proportions and correlations; Pearson chi-square goodness of fit, contingency tables, degrees of freedom and pitfalls.
- 15 min
On this page · 12 sections
Prerequisites
- Sampling Distributions, Standard Errors and Order Statistics: standard errors, the CLT, Slutsky’s theorem and Fisher’s \( z \).
- Hypothesis Testing: MP, UMP and Likelihood Ratio Tests: size, power, p-values and Wilks’ theorem.
- Standard Discrete and Continuous Distributions: the multinomial, binomial and Poisson models behind count data.
The Hook: Is the Die Fair?
Large-Sample Tests
Principle. If \( T \) estimates \( \theta \) and, for large \( n \), \( \frac{T - \theta}{\text{SE}(T)} \approx N(0, 1) \), then under \( H_0: \theta = \theta_0 \)
$$Z = \frac{T - \theta_0}{\text{SE}(T)} \approx N(0, 1),$$with the SE evaluated under \( H_0 \) where it depends on \( \theta \), or estimated consistently otherwise (Slutsky). No normality of the population is needed; only a large sample.
Critical values of \( Z \)
| Level | Two-tailed (\( \lvert Z \rvert > \)) | Right-tailed (\( Z > \)) | Left-tailed (\( Z < \)) |
|---|---|---|---|
| 5% | 1.96 | 1.645 | \( -1.645 \) |
| 1% | 2.576 | 2.326 | \( -2.326 \) |
The standard \( Z \) statistics
| \( H_0 \) | Statistic | Standard error |
|---|---|---|
| \( \mu = \mu_0 \) | \( \frac{\bar{x} - \mu_0}{\text{SE}} \) | \( \frac{\sigma}{\sqrt{n}} \), or \( \frac{s}{\sqrt{n}} \) |
| \( \mu_1 = \mu_2 \) | \( \frac{\bar{x}_1 - \bar{x}_2}{\text{SE}} \) | \( \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}} \) |
| \( p = p_0 \) | \( \frac{\hat{p} - p_0}{\text{SE}} \) | \( \sqrt{\frac{p_0q_0}{n}} \) (null value) |
| \( p_1 = p_2 \) | \( \frac{\hat{p}_1 - \hat{p}_2}{\text{SE}} \) | \( \sqrt{\hat{p}\hat{q}\left(\frac{1}{n_1} + \frac{1}{n_2}\right)} \), pooled \( \hat{p} = \frac{x_1 + x_2}{n_1 + n_2} \) |
| \( \sigma_1 = \sigma_2 \) | \( \frac{s_1 - s_2}{\text{SE}} \) | \( \sqrt{\frac{s_1^2}{2n_1} + \frac{s_2^2}{2n_2}} \) (normal populations) |
| \( \rho = \rho_0 \) (bivariate normal) | \( (z_r - z_{\rho_0})\sqrt{n - 3} \) | Fisher’s \( z_r = \tanh^{-1}r \) |
| \( \rho_1 = \rho_2 \) | \( \frac{z_{r_1} - z_{r_2}}{\text{SE}} \) | \( \sqrt{\frac{1}{n_1 - 3} + \frac{1}{n_2 - 3}} \) |
Small-sample exact counterparts
When the population is normal and \( n \) is small, replace \( z \) by the exact laws:
| Problem | Statistic | Null law |
|---|---|---|
| \( \mu = \mu_0 \), \( \sigma \) unknown | \( \frac{\sqrt{n}(\bar{x} - \mu_0)}{s} \) | \( t_{n-1} \) |
| \( \mu_1 = \mu_2 \), equal variances | pooled \( t \) | \( t_{n_1 + n_2 - 2} \) |
| paired data, mean difference 0 | \( \frac{\sqrt{n}\,\bar{d}}{s_d} \) | \( t_{n-1} \) |
| \( \sigma^2 = \sigma_0^2 \) | \( \frac{(n-1)s^2}{\sigma_0^2} \) | \( \chi^2_{n-1} \) |
| \( \sigma_1^2 = \sigma_2^2 \) | \( \frac{s_1^2}{s_2^2} \) | \( F_{n_1-1,\,n_2-1} \) |
| \( \rho = 0 \) | \( \frac{r\sqrt{n - 2}}{\sqrt{1 - r^2}} \) | \( t_{n-2} \) |
Pearson’s Chi-Square Goodness-of-Fit Test
Setting. \( N \) observations fall into \( k \) mutually exclusive classes with observed counts \( O_1, \dots, O_k \). Under \( H_0 \), class \( i \) has probability \( p_i \) (possibly depending on unknown parameters), so the expected count is \( E_i = Np_i \).
If the \( p_i \) are fully specified, \( \chi^2 \xrightarrow{d} \chi^2_{k-1} \) under \( H_0 \) as \( N \to \infty \). If \( s \) parameters are estimated from the data (efficiently, from the grouped counts), the limit is \( \chi^2_{k-1-s} \). Large values of \( \chi^2 \) lead to rejection.
Why \( k - 1 \). The counts satisfy one linear constraint, \( \sum O_i = N \). Each parameter estimated from the data imposes one more. (The \( k = 2 \) case is the square of the proportion \( Z \): \( \frac{(O_1 - Np)^2}{Np} + \frac{(O_2 - Nq)^2}{Nq} = \frac{(O_1 - Np)^2}{Npq} \).)
| Fitting | Parameters estimated \( s \) | Degrees of freedom |
|---|---|---|
| fully specified probabilities (fair die, 9:3:3:1) | 0 | \( k - 1 \) |
| binomial with \( n \) known, \( p \) estimated | 1 | \( k - 2 \) |
| Poisson, \( \lambda \) estimated | 1 | \( k - 2 \) |
| normal, \( \mu \) and \( \sigma \) estimated | 2 | \( k - 3 \) |
Conditions and practice.
- The approximation is asymptotic. A common textbook rule of thumb asks every expected count to be at least 5; classes with small \( E_i \) are pooled with neighbours, and \( k \) is the number of classes after pooling.
- Use counts, never percentages or proportions: \( \chi^2 \) scales with \( N \).
- The test is two-sided in spirit but uses the right tail. A suspiciously small \( \chi^2 \) (fit “too good to be true”) is sometimes checked in the left tail.
- The likelihood ratio statistic \( G^2 = 2\sum O_i\log\frac{O_i}{E_i} \) has the same limit; Pearson’s \( \chi^2 \) is its quadratic approximation.
Contingency Tables: Independence and Homogeneity
An \( r \times c \) table cross-classifies \( N \) individuals by two attributes, with cell counts \( O_{ij} \), row totals \( R_i \), column totals \( C_j \). Under \( H_0 \) (the attributes are independent, or equivalently the row populations have the same column distribution), the estimated expected count is
$$E_{ij} = \frac{R_iC_j}{N}, \qquad \chi^2 = \sum_{i,j}\frac{(O_{ij} - E_{ij})^2}{E_{ij}} \approx \chi^2_{(r-1)(c-1)}.$$Degrees of freedom. \( rc - 1 \) free cells, minus \( (r - 1) + (c - 1) \) estimated marginal probabilities: \( (r - 1)(c - 1) \). Equivalently, once \( (r-1)(c-1) \) cells are filled, the margins fix the rest.
Independence vs homogeneity. In a test of independence one sample of size \( N \) is cross-classified; in a test of homogeneity the row totals are fixed by design (separate samples). The statistic, expected counts and degrees of freedom are the same.
The \( 2 \times 2 \) shortcut. For the table \( \begin{pmatrix} a & b \\ c & d \end{pmatrix} \), \( N = a + b + c + d \):
$$\chi^2 = \frac{N(ad - bc)^2}{(a + b)(c + d)(a + c)(b + d)}, \quad 1 \text{ degree of freedom}.$$This equals the square of the pooled two-proportion \( Z \). Yates’ continuity correction replaces \( \lvert ad - bc \rvert \) by \( \lvert ad - bc \rvert - \frac{N}{2} \) (when positive) to improve the approximation for small counts; for very small tables, Fisher’s exact test (hypergeometric, conditioning on the margins) is used instead.
graph TD
A["Count data"] --> B{"One classification or two?"}
B -->|"one: k classes"| C["Goodness of fit: E = N p"]
C --> D["df = k - 1 - (parameters estimated)"]
B -->|"two: r x c table"| E["Independence / homogeneity: E = R C / N"]
E --> F["df = (r - 1)(c - 1)"]
D --> G["Pool classes with small E first"]
F --> GMemory Tricks
- “Observed squared over expected, minus N.” \( \sum O^2/E - N \) is the fastest way to compute \( \chi^2 \) by hand.
- “Lose one for the total, one per parameter.” Goodness-of-fit degrees of freedom \( = k - 1 - s \).
- “Rows minus one times columns minus one.” Contingency degrees of freedom.
- “Test with \( p_0 \), interval with \( \hat{p} \).” The SE for testing a single proportion uses the null value.
- 1.645, 1.96, 2.326, 2.576. One-tailed 5%, two-tailed 5%, one-tailed 1%, two-tailed 1%. And \( \chi^2_1 \) critical values are their squares: \( 1.96^2 \approx 3.84 \), \( 2.576^2 \approx 6.63 \).
Don’t Confuse
| This | Is not this | The difference |
|---|---|---|
| goodness of fit (\( k - 1 - s \) df) | independence (\( (r-1)(c-1) \) df) | one classification vs two |
| SE with \( p_0 \) (test) | SE with \( \hat{p} \) (interval) | null value fixes the variance |
| pooled \( \hat{p} \) for \( p_1 = p_2 \) | separate \( \hat{p}_1, \hat{p}_2 \) | under \( H_0 \) there is one common \( p \) |
| \( \chi^2 \) on counts | \( \chi^2 \) on percentages | the statistic is not scale-free |
| \( k \) before pooling | \( k \) after pooling | degrees of freedom use the classes actually tested |
| large-sample \( z \) | exact \( t \) | \( t \) needs normality; \( z \) needs large \( n \) |
Common Mistakes
Practice
All questions below are original practice questions written for this page. They are not from any CSIR NET paper. In Level 3, as in Part C, one or more options may be correct.
Level 1: Foundation
- How many degrees of freedom does a goodness-of-fit test with 6 fully specified classes have?
- How many degrees of freedom does a \( 3 \times 4 \) contingency table test have?
- What is the two-tailed 5% critical value of \( Z \)?
Answers
- \( (3 - 1)(4 - 1) = 6 \).
- 1.96.
Level 2: Part B Style
Practice Q1. A die is rolled 60 times, giving counts 8, 9, 10, 11, 12, 10 for faces 1 to 6. Pearson’s \( \chi^2 \) for fairness is:
(a) 0.5 (b) 1.0 (c) 2.0 (d) 10.0
Answer: (b)
\( \frac{(8-10)^2 + (9-10)^2 + 0 + (11-10)^2 + (12-10)^2 + 0}{10} = \frac{10}{10} = 1.0 \).
Practice Q2. For the \( 2 \times 2 \) table with rows \( (20, 30) \) and \( (30, 20) \), the uncorrected \( \chi^2 \) statistic is:
(a) 1.0 (b) 2.0 (c) 4.0 (d) 8.0
Answer: (c)
\( \frac{100(400 - 900)^2}{50 \cdot 50 \cdot 50 \cdot 50} = 4.0 \).
Practice Q3. In a sample of 400, 220 favour a proposal. The \( Z \) statistic for \( H_0: p = 0.5 \) is:
(a) 1.0 (b) 1.96 (c) 2.0 (d) 2.2
Answer: (c)
\( \frac{0.55 - 0.50}{\sqrt{0.25/400}} = \frac{0.05}{0.025} = 2.0 \). Using \( \hat{p}\hat{q} \) gives SE \( \approx 0.0249 \) and \( Z \approx 2.01 \), the same to two figures; the null value is the standard choice.
Practice Q4. A Poisson distribution, with \( \lambda \) estimated by the sample mean, is fitted to data grouped into 6 classes (no pooling needed). The degrees of freedom of the \( \chi^2 \) test are:
(a) 6 (b) 5 (c) 4 (d) 3
Answer: (c)
\( k - 1 - s = 6 - 1 - 1 = 4 \).
Level 3: Part C Style
Practice Q5. Two independent samples of 100 each give \( \bar{x}_1 = 52 \), \( s_1 = 6 \) and \( \bar{x}_2 = 50 \), \( s_2 = 8 \). Test \( H_0: \mu_1 = \mu_2 \). Which statements are true?
(a) The large-sample \( Z \) statistic is 2. (b) \( H_0 \) is rejected at the 5% level against \( \mu_1 \ne \mu_2 \). (c) \( H_0 \) is rejected at the 1% level against \( \mu_1 \ne \mu_2 \). (d) The one-sided p-value against \( \mu_1 > \mu_2 \) is about 0.023.
Answer: (a), (b) and (d)
- (a) True. SE \( = \sqrt{\frac{36}{100} + \frac{64}{100}} = 1 \); \( Z = 2 \).
- (b) True. \( 2 > 1.96 \).
- (c) False. \( 2 < 2.576 \).
- (d) True. \( 1 - \Phi(2) \approx 0.0228 \).
Practice Q6. A cross is expected to give four classes in the ratio 9 : 3 : 3 : 1. Among 160 offspring the observed counts are 96, 28, 26, 10. Use \( \chi^2_{3,0.05} \approx 7.815 \). Which statements are true?
(a) The expected counts are 90, 30, 30, 10. (b) Pearson’s \( \chi^2 \) is about 1.07. (c) The test has 3 degrees of freedom. (d) The 9 : 3 : 3 : 1 hypothesis is rejected at the 5% level.
Answer: (a), (b) and (c)
- (a) True. \( 160 \times \frac{9}{16}, \frac{3}{16}, \frac{3}{16}, \frac{1}{16} \).
- (b) True. \( \frac{36}{90} + \frac{4}{30} + \frac{16}{30} + 0 = 0.4 + 0.133 + 0.533 \approx 1.067 \).
- (c) True. Four classes, ratio fully specified: \( 4 - 1 = 3 \).
- (d) False. \( 1.07 < 7.815 \).
Practice Q7. In two independent samples of 200, 60 and 40 individuals respectively have a trait. Test \( H_0: p_1 = p_2 \). Which statements are true?
(a) The pooled estimate of the common proportion is 0.25. (b) The two-proportion \( Z \) statistic is about 2.31. (c) The uncorrected \( \chi^2 \) for the \( 2 \times 2 \) table (trait yes/no by sample) is about 5.33. (d) \( H_0 \) is rejected at the 1% level against \( p_1 \ne p_2 \).
Answer: (a), (b) and (c)
- (a) True. \( \frac{60 + 40}{400} = 0.25 \).
- (b) True. SE \( = \sqrt{0.25 \times 0.75 \times \frac{2}{200}} \approx 0.0433 \); \( Z = \frac{0.30 - 0.20}{0.0433} \approx 2.31 \).
- (c) True. \( \frac{400(60 \cdot 160 - 140 \cdot 40)^2}{200 \cdot 200 \cdot 100 \cdot 300} = \frac{400 \times 4000^2}{1.2 \times 10^9} \approx 5.33 = Z^2 \).
- (d) False. \( 2.31 < 2.576 \) (equivalently \( 5.33 < 6.63 \)). It is rejected at 5%.
Quick Revision Table
| Test | Statistic | Null law / df |
|---|---|---|
| Large-sample mean | \( \frac{\bar{x} - \mu_0}{s/\sqrt{n}} \) | \( N(0, 1) \) |
| Two means | \( \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{s_1^2/n_1 + s_2^2/n_2}} \) | \( N(0, 1) \) |
| Proportion | \( \frac{\hat{p} - p_0}{\sqrt{p_0q_0/n}} \) | \( N(0, 1) \) |
| Two proportions | pooled \( \hat{p} \) in the SE | \( N(0, 1) \); square = \( 2 \times 2 \) \( \chi^2 \) |
| Correlation | \( (z_r - z_{\rho_0})\sqrt{n - 3} \) | \( N(0, 1) \) |
| Goodness of fit | \( \sum \frac{(O - E)^2}{E} \) | \( \chi^2_{k-1-s} \) |
| Independence | \( E_{ij} = R_iC_j/N \) | \( \chi^2_{(r-1)(c-1)} \) |
| \( 2 \times 2 \) | \( \frac{N(ad - bc)^2}{(a+b)(c+d)(a+c)(b+d)} \) | \( \chi^2_1 \) |
| Critical values | \( z \): 1.645, 1.96, 2.326, 2.576 | \( \chi^2_1 \): 3.84 (5%), 6.63 (1%) |
Key Takeaways
What’s Next
- Nonparametric Tests, Rank Correlation and Bayesian Inference: tests that need neither normality nor large samples, and the Bayesian alternative.
- Hypothesis Testing: MP, UMP and Likelihood Ratio Tests: where the \( \chi^2 \) limit comes from (Wilks).
- Tables, Caselets and Combined Data: the Part A skill of reading row and column totals quickly.
- Back to the chapter overview.