01 / 20
\(\chi^2\)

The Chi-Square
Distribution

Master the right-skewed distribution that powers categorical inference: from goodness-of-fit tests to tests of independence.

Biostatistics

What is the Chi-Square Distribution?

When you square independent standard normal variables and add them together, the result follows a chi-square distribution. If \( Z_1, Z_2, \ldots, Z_k \) are independent \( N(0,1) \) variables, then:

The parameter \( k \) is called the degrees of freedom (df). It controls the shape, center, and spread of the distribution.

Why Does It Matter in Biostatistics?

Categorical Data
Most biological and clinical outcomes are counted in categories: disease/no disease, genotype AA/Aa/aa, treatment response levels.
Hypothesis Testing
The chi-square test asks: do observed category counts differ significantly from what we expected under a null hypothesis?
Versatility
Goodness-of-fit, tests of independence, and homogeneity tests all rely on the same \( \chi^2 \) distribution.

Shape Across Degrees of Freedom

Key Properties

1
Always non-negative: Since it is a sum of squares, \( \chi^2 \geq 0 \).
2
Right-skewed: Skewness decreases as \( k \) grows. For large \( k \), the curve approximates a normal distribution.
3
Mean = \( k \), Variance = \( 2k \): These follow directly from the definition as a sum of \( k \) squared standard normals.
4
Additive: If \( X \sim \chi^2(m) \) and \( Y \sim \chi^2(n) \) are independent, then \( X + Y \sim \chi^2(m + n) \).

The Test Statistic

For both goodness-of-fit and independence tests, the test statistic has the same form. Let \( O_i \) be the observed count and \( E_i \) the expected count for category \( i \):

A large \( \chi^2 \) value means observed data deviate greatly from expectation, providing evidence against the null hypothesis.

Goodness-of-Fit vs Independence

Goodness-of-Fit Test of Independence
Purpose Does one variable match a theoretical distribution? Are two categorical variables related?
Data layout One row of counts Two-way contingency table
Degrees of freedom \( k - 1 \) \( (r-1)(c-1) \)
\( H_0 \) Observed fits expected proportions Variables are independent
Example Mendelian \( 9:3:3:1 \) ratio Drug vs placebo outcome

How to Perform a Chi-Square Test

1
State hypotheses: \( H_0 \): observed counts match expected. \( H_a \): they do not.
2
Check conditions: Random sample, independent observations, and all expected counts \( E_i \geq 5 \).
3
Calculate expected counts. For goodness-of-fit: \( E_i = n \cdot p_i \). For independence: \( E_{ij} = \frac{(\text{row total})(\text{col total})}{n} \).
4
Compute the test statistic: \( \chi^2 = \sum \frac{(O_i - E_i)^2}{E_i} \).
5
Find the p-value from the \( \chi^2 \) table using the appropriate df. Reject \( H_0 \) if \( p < \alpha \).

Example 1: Mendelian Genetics

A geneticist crosses two heterozygous pea plants and observes 320 offspring. Under the Mendelian \( 3:1 \) ratio, we expect 240 dominant and 80 recessive. The observed counts are 218 dominant and 102 recessive.

Example 2: Test of Independence

A clinical trial tests whether treatment type (Drug A vs Drug B) is associated with outcome (Improved vs Not Improved). Here is the \( 2 \times 2 \) table of observed counts:

Improved Not Improved Total
Drug A 45 15 60
Drug B 30 30 60
Total 75 45 120

Example 2: Calculation

Example 3: Blood Type Distribution

A researcher surveys 200 patients and wants to test whether the distribution matches the known population proportions: O = 45%, A = 40%, B = 11%, AB = 4%.

O A B AB
Observed 85 76 28 11
Expected 90 80 22 8

Reading the Critical Value Table

df \( \alpha = 0.10 \) \( \alpha = 0.05 \) \( \alpha = 0.01 \)
12.7063.8416.635
24.6055.9919.210
36.2517.81511.345
47.7799.48813.277
59.23611.07015.086

Conditions and Assumptions

Random Sampling
Data must come from a random sample or randomized experiment.
Independence
Each observation is independent. Sample size should be \( < 10\% \) of the population.
Expected Counts
All expected cell counts must be at least 5. If not, combine categories or use Fisher's exact test.

Common Mistakes to Avoid

✕ Using Percentages
The formula requires raw counts, not proportions or percentages. Always convert back to counts first.
✕ Wrong df
Goodness-of-fit: \( k - 1 \). Independence: \( (r-1)(c-1) \). Mixing these up changes the critical value entirely.
✕ Small Expected Counts
If any \( E_i < 5 \), the chi-square approximation breaks down. Combine categories or use an exact test.

Question 1 of 5

A chi-square goodness-of-fit test has 6 categories. What are the degrees of freedom?

Question 2 of 5

In a \( 3 \times 4 \) contingency table, what are the degrees of freedom for a test of independence?

Question 3 of 5

For a category with observed count 30 and expected count 25, what is the contribution to \( \chi^2 \)?

Question 4 of 5

A researcher calculates \( \chi^2 = 4.12 \) with \( \text{df} = 2 \). The critical value at \( \alpha = 0.05 \) is 5.991. What is the correct conclusion?

Question 5 of 5

Which condition must be met before performing a chi-square test?