Methods and formulas for Chi-Square Goodness-of-Fit Test

Select the method or formula of your choice.

Expected value for each category

Formula

The expected value, E, for each category, i, is calculated as:

Notation

TermDescription
pi test proportion for the i th category, which equals 1/k or the value you provide
k number of distinct categories
N total observed values (O1 + ... + Ok)
Oi observed value for the i th category

Chi-Square test statistic

Formula

The chi-square test statistic is calculated as:

Notation

TermDescription
k number of distinct categories
Oi observed value for the i th category
Ei expected value for the i th category

Contribution to chi-square statistic

Formula

Contribution of the i th category to the chi-square value is:

Notation

TermDescription
Oi observed value for the i th category
Ei expected value for the i th category

Degrees of freedom (DF)

Formula

The degrees of freedom (DF) is calculated as:

Notation

TermDescription
DFdegrees of freedom
knumber of categories

P-value

Formula

The p-value is calculated as: Prob (Χ > Test statistic)

Notation

TermDescription
X follows a chi-square distribution with k – 1 degrees of freedom

Example computation

Given:
Category i Observed Oi Test proportions pi
A 5 0.1
B 15 0.2
C 10 0.3
D 10 0.4
  N=40  
Calculated:
Category i Expected value

Ei = (pi * N)

Contribution to chi-square

(Oi- Ei)2 / Ei

A 0.1 * 40 = 4 (5 – 4)2 / 4 = 0.2500
B 0.2 * 40 = 8 (15 – 8)2 / 8 = 6.1250
C 0.3 * 40 = 12 (10 – 12)2 / 12 = 0.3333
D 0.4 * 40 = 16 (10 – 16)2 / 16 = 2.2500

χ2 = 0.2500 + 6.1250 + 2.2500 + 0.3333 = 8.9583

DF = k – 1 = 3

p-value = Prob (Χ > 8.9583) = 0.0299

Notation

TermDescription
DFdegrees of freedom
knumber of categories
By using this site you agree to the use of cookies for analytics and personalized content.  Read our policy