Biostatistics Study NotesFrom concepts and derivations to interpretation

CHAPTER 05 · TOPIC 02

Chi-Square Goodness-of-Fit Test

Compare observed counts with counts expected from specified theoretical proportions to assess an entire categorical distribution.

On this page
  1. From binomial distribution to multinomial distribution
  2. Data and model conditions
  3. Hypotheses
  4. Pearson chi-square statistic
  5. For two categories
  6. The reason why the degree of freedom is k−1
  7. Difference with independence test
  8. Testing Procedure

The chi-square goodness-of-fit test examines whether the observed frequencies of a categorical variable fit a prespecified theoretical proportion.

From binomial distribution to multinomial distribution#

If the probability of k exclusive categories is π₁,…,πk and the frequency is O₁,…,Ok, then the frequency vector follows a multinomial distribution.

sum of probabilitiesi=1kπi=1\sum_{i=1}^{k}\pi_i=1
Expected countEi=nπiE_i=n\pi_i
Total frequencyi=1kOi=n\sum_{i=1}^{k}O_i=n

Data and model conditions#

  • Each unit of observation falls into only one category
  • Observations are independent
  • The total theoretical ratio is 1
  • Chi-square approximation has sufficient expected power

Hypotheses#

null hypothesisH0:π1=π10,,πk=πk0H_0:\pi_1=\pi_{10},\ldots,\pi_k=\pi_{k0}
alternative hypothesisH1:at least one πiπi0H_1:\text{at least one }\pi_i\ne\pi_{i0}

Pearson chi-square statistic#

statisticsχ2=i=1k(OiEi)2Ei\chi^2=\sum_{i=1}^{k}\frac{(O_i-E_i)^2}{E_i}
Degrees of Freedomν=k1m\nu=k-1-m

For two categories#

O₁=a, O₂=n−a, and substituting the expected values ​​np and n(1−p) corresponds to the square of the one-proportion Z statistic.

Two categories χ²χ2=(anp)2np(1p)\chi^2=\frac{(a-np)^2}{np(1-p)}
Relationship with Zχ2=Z2\chi^2=Z^2

The reason why the degree of freedom is k−1#

Since the total number n is fixed, when k−1 frequencies are determined, the last one is automatically determined. If m parameters are estimated from the same data, subtract m further.

Difference with independence test#

methodNumber of variablesExpected count
goodness of fit testone categorical variableCalculated from pre-specified theoretical proportions
independence testtwo categorical variablesEstimated from row and column marginal proportions

Testing Procedure#

  1. Predefine categories and theoretical proportions
  2. Calculate Eᵢ=nπᵢ and check the approximation conditions
  3. Calculate Pearson χ² and degrees of freedom
  4. Determine suitability from the right tail p-value
  5. If significant, check the residuals for each category and interpret the location of the deviation.