5.06d - Chi-squared goodness of fit tests

5.06d - Chi-squared goodness of fit tests

Use expected frequencies to test whether a proposed probability distribution is compatible with observed data. You will combine adjacent classes, allow for parameters estimated from the sample, choose a critical value and give a conclusion that distinguishes lack of evidence from proof of a model.

Testing given proportions

Can the same observed and expected frequency tables lead to different goodness of fit decisions? They can, when the hypotheses used different amounts of information from the sample. We will first test a fully specified model, then see why estimating a parameter changes the comparison.

You already know

For a proposed model, Ei=NpiE_i=Np_i. Continuous class probabilities are areas or c.d.f. differences; unbounded models need a final tail class. An independence test compares two categorical variables, while a goodness of fit test compares one observed distribution with a proposed model.

The null hypothesis states the proposed population distribution. The alternative says it does not have that distribution. For example, H0H_0: category probabilities are in the ratio 2:3:52:3:5; H1H_1: they are not in that ratio. Do not put “there is evidence” into the hypotheses: evidence is what the test will assess.

Goodness of fit statistic

For mutually exclusive, exhaustive classes with expected frequencies Ei≥5E_i\ge5,

X2=∑i(Oi−Ei)2EiX^2=\sum_i\frac{(O_i-E_i)^2}{E_i}

Under the null hypothesis, this is approximately distributed as χν2\chi^2_\nu, with appropriate degrees of freedom.
In the formula booklet.

For kk retained classes and a fully specified model, ν=k−1\nu=k-1, because the frequencies sum to the fixed total NN. This degrees-of-freedom rule is not printed in the booklet. Large discrepancies give large statistics, so use an upper-tail critical value. The critical-value table is in the formula booklet.

Worked example 1: a fully specified ratio

Question. A random sample of 100100 independent observations has category frequencies 12,28,6012,28,60. Test at the 5%5\% level whether the population proportions are in the ratio 2:3:52:3:5.

Plan. State the ratio hypotheses, find expected frequencies, calculate the statistic and use 3−13-1 degrees of freedom.

H0H_0: population proportions are 2:3:52:3:5. H1H_1: they are not 2:3:52:3:5.

(E1,E2,E3)=100(0.2,0.3,0.5)=(20,30,50)given proportionsX2=(12−20)220+(28−30)230+(60−50)250all three contributions=163=5.333…sumν=3−1=2,5.333…<5.991upper 5% critical value\begin{aligned} (E_1,E_2,E_3)&=100(0.2,0.3,0.5)=(20,30,50) &&\text{given proportions}\\ X^2&=\frac{(12-20)^2}{20}+\frac{(28-30)^2}{30}+\frac{(60-50)^2}{50} &&\text{all three contributions}\\ &=\frac{16}{3}=5.333\ldots &&\text{sum}\\ \nu&=3-1=2,\qquad 5.333\ldots<5.991 &&\text{upper }5\%\text{ critical value} \end{aligned}

Why this step? The ratio is specified before using the sample; no parameter has been adjusted to make the model fit better.

Answer. Do not reject H0H_0. There is insufficient evidence at the 5%5\% level that the population proportions differ from 2:3:52:3:5.

Check. Expected frequencies sum to 100100 and all exceed 55; the contributions are approximately 3.2,0.133,23.2,0.133,2.

Worked example 2 changes only the observed allocation between the first two categories. Keep the hypothesis, expected frequencies and critical value fixed.

Worked example 2: a larger discrepancy

Question. For the same proposed ratio, another random sample of 100100 independent observations has frequencies 8,32,608,32,60. Carry out the 5%5\% goodness of fit test.

Plan. Use the same expected table and calculate the new contributions.

The hypotheses remain H0H_0: population proportions are 2:3:52:3:5; H1H_1: they are not.

X2=(8−20)220+(32−30)230+(60−50)250expectations 20,30,50=283=9.333…sumν=2,9.333…>5.991upper-tail comparison\begin{aligned} X^2&=\frac{(8-20)^2}{20}+\frac{(32-30)^2}{30}+\frac{(60-50)^2}{50} &&\text{expectations }20,30,50\\ &=\frac{28}{3}=9.333\ldots &&\text{sum}\\ \nu&=2,\qquad 9.333\ldots>5.991 &&\text{upper-tail comparison} \end{aligned}

Why this step? Squaring the larger first-category discrepancy increases its contribution from 64/2064/20 to 144/20144/20.

Answer. Reject H0H_0. There is sufficient evidence at the 5%5\% level that the population proportions differ from 2:3:52:3:5.

Check. The first contribution is 7.27.2, so the full statistic must already exceed 5.9915.991.

A goodness of fit test does not use Yates’s correction, even with only two retained classes or one degree of freedom. In this course that correction belongs to a two-by-two contingency table for independence.

Exam tip

Give the statistic, retained degrees of freedom, critical value and numerical comparison before the conclusion. A non-significant result needs “insufficient evidence that the model does not fit”, or equivalent qualified wording, rather than “the model is correct”.

Keep the conclusion attached to the population proportions the question actually proposed.

Pooling adjacent classes

Pool adjacent classes until every expected frequency in the retained table is at least 55, then calculate both the statistic and degrees of freedom from that table.

Add the observed frequencies and the expected frequencies separately. In particular,

(O1+O2−E1−E2)2E1+E2\frac{(O_1+O_2-E_1-E_2)^2}{E_1+E_2}

is the pooled contribution; adding the old individual contributions is generally different. This expression follows from the booklet's statistic and is not separately printed there. Decide pooling from expected sizes, without choosing groups to obtain a preferred test outcome.

Worked example 3: merge a small upper tail

Question. A fixed Geo(1/2)\mathrm{Geo}(1/2) model is proposed for 8080 independent trial counts. For classes 1,2,3,4,5,6,≥71,2,3,4,5,6,\ge7, the observed frequencies are 35,25,9,7,2,1,135,25,9,7,2,1,1. Carry out a 5%5\% goodness of fit test.

Plan. Include the infinite tail, combine its small adjacent classes, then test the retained table.

H0H_0: trial counts have distribution Geo(1/2)\mathrm{Geo}(1/2). H1H_1: they do not.

E=(40,20,10,5,2.5,1.25,1.25)geometric probabilities times 80E≥5=2.5+1.25+1.25=5pool the last three classesO≥5=2+1+1=4pool the same observations\begin{aligned} E&=(40,20,10,5,2.5,1.25,1.25) &&\text{geometric probabilities times }80\\ E_{\ge5}&=2.5+1.25+1.25=5 &&\text{pool the last three classes}\\ O_{\ge5}&=2+1+1=4 &&\text{pool the same observations} \end{aligned}

The retained classes are 1,2,3,4,≥51,2,3,4,\ge5, with observed frequencies (35,25,9,7,4)(35,25,9,7,4) and expectations (40,20,10,5,5)(40,20,10,5,5).

X2=2540+2520+110+45+15pooled contributions=2.975sumν=5−1=4,2.975<9.488upper 5% critical value\begin{aligned} X^2&=\frac{25}{40}+\frac{25}{20}+\frac1{10}+\frac4{5}+\frac1{5} &&\text{pooled contributions}\\ &=2.975 &&\text{sum}\\ \nu&=5-1=4,\qquad 2.975<9.488 &&\text{upper }5\%\text{ critical value} \end{aligned}

Why this step? Combining only the last two classes gives expectation 2.52.5, still too small. The tail must begin at 55 here.

Answer. Do not reject H0H_0. There is insufficient evidence at the 5%5\% level that these trial counts do not follow the specified geometric distribution.

Check. Both retained tables sum to 8080, and the smallest retained expectation is 55.

Worked example 4 changes only the sample size to 4040, with another set of observed counts. Halving the model expectations forces the tail to begin one class earlier.

Worked example 4: a smaller sample needs more pooling

Question. For the same fixed Geo(1/2)\mathrm{Geo}(1/2) model, 4040 independent observations give frequencies 19,9,7,2,1,1,119,9,7,2,1,1,1 in the same original classes. Carry out a 5%5\% test.

Plan. Recalculate expectations for N=40N=40, then find the smallest suitable upper-tail group.

The hypotheses remain the same fixed geometric model and its negation.

E=(20,10,5,2.5,1.25,0.625,0.625)halve the expectationsE≥4=2.5+1.25+0.625+0.625=5combine from 4O≥4=2+1+1+1=5same observed classesX2=(19−20)220+(9−10)210+(7−5)25+0four retained classes=0.95sumν=4−1=3,0.95<7.815upper 5% critical value\begin{aligned} E&=(20,10,5,2.5,1.25,0.625,0.625) &&\text{halve the expectations}\\ E_{\ge4}&=2.5+1.25+0.625+0.625=5 &&\text{combine from }4\\ O_{\ge4}&=2+1+1+1=5 &&\text{same observed classes}\\ X^2&=\frac{(19-20)^2}{20}+\frac{(9-10)^2}{10}+\frac{(7-5)^2}{5}+0 &&\text{four retained classes}\\ &=0.95 &&\text{sum}\\ \nu&=4-1=3,\qquad 0.95<7.815 &&\text{upper }5\%\text{ critical value} \end{aligned}

Why this step? The original class boundaries are not sacred: the expected-frequency requirement determines the retained boundaries before the statistic is formed.

Answer. Do not reject H0H_0. There is insufficient evidence at the 5%5\% level against the specified geometric model for these trial counts.

Check. Retained expectations (20,10,5,5)(20,10,5,5) and observations (19,9,7,5)(19,9,7,5) both sum to 4040.

[DIAGRAM: asset_name: Pooling changes the number of retained classes; asset_slug: h245_5_06_pooling_geometric_tail; caption: With 80 observations the retained tail starts at 5, while with 40 it must start at 4; description: Two rows of class boxes show geometric expected frequencies for success probability one half. The upper row for sample size 80 shows 40, 20, 10, 5, 2.5, 1.25, 1.25 in classes 1, 2, 3, 4, 5, 6, at least 7. The final three combine into a tail of expected size 5. The lower row for sample size 40 shows 20, 10, 5, 2.5, 1.25, 0.625, 0.625. The final four combine into a tail of expected size 5. The resulting retained class counts are five and four respectively]
With 80 observations the retained tail starts at 5, while with 40 it must start at 4

Pooling applies equally to continuous intervals: adjacent intervals become their union, and an open final tail remains included. If pooling leaves too few classes for positive degrees of freedom, the proposed chi-squared procedure cannot be used.

Watch out

Wrong: pool because an observed frequency is below 55, then keep the old degrees of freedom. Right: pool because an expected frequency is below 55, and count the classes after pooling.

Recheck the sum of expectations and the smallest expectation before moving to the critical-value table.

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account