Sei sulla pagina 1di 19

MATH& 146

Lesson 25
Section 3.3
The Goodness of Fit Test

1
Goodness of Fit Test
Suppose that you want to determine whether
observed sample frequencies differ significantly
from expected frequencies specified in the null
hypothesis.
This test can be addressed using the chi-square
goodness of fit test.

2
The Hypotheses
In the goodness of fit test, the counts in each bin of
the observed data are compared to the counts in
each bin some expected distribution. That is,
H0: The data is behaving according to the
expected distribution.
HA: The data is not behaving according to the
expected distribution.

3
The Hypotheses
In statistical notation, the hypotheses are

H0 : pcategory 1 p1
pcategory 2 p2

pcategory k pk

H A : At least one proportion is different


than expected.
4
Expected Value
To find the expected value, we multiply the null
values by the number of trials.
That is, E = np.
For example, if we flip a coin 80 times, we would
expect 40 heads and 40 tails.

5
Example 1
A bag of Hershey's Miniatures was opened and the
number of each candy was counted. If there were
132 candies total, then how many of each of the
four candies should you expect if each candy was
equally likely?
Brand Observed Expected
Krackel 33
Mr. Goodbar 32
Milk Chocolate 37
Dark Chocolate 30
Total 132 132 6
Chi-Square Test for One-Way Table

Suppose we are to evaluate whether there is


convincing evidence that a set of observed counts
O1, O2, ..., Ok in k categories are unusually
different from what might be expected under a null
hypothesis.
Call the expected counts that are based on the null
hypothesis E1, E2, ..., Ek.

7
Chi-Square Test for One-Way Table

If the conditions are met, then the test statistic


below follows a chi-square distribution with k 1
degrees of freedom:

O1 E1 O2 E2 Ok Ek
2 2 2

2

E1 E2 Ek

8
Example 2
Calculate the chi-square test statistic.

Brand Observed Expected


Krackel 33 33
Mr. Goodbar 32 33
Milk Chocolate 37 33
Dark Chocolate 30 33
Total 132 132 9
Conditions
There are three conditions that must be checked
before performing a chi-square test:
1) Independence: Each case that contributes a
count to the table must be independent of all the
other cases in the table.
2) Sample size / distribution: Each particular
scenario (i.e. cell count) must have at least five (5)
expected cases.
3) Number of groups: The proportions of at least
three (3) groups are being tested.

10
Chi-Square Test for One-Way Table

The p-value for this test statistic can be found with the
2cdf command to find the area of the upper tail of this
chi-square distribution. We consider the upper tail
because larger values of 2 would provide greater
evidence against the null hypothesis.


p-value 2cdf 2 -test statistic, BIG, df
df stands for the degrees of freedom and, for this
test, is the number of groups minus one: df = k 1.

11
Example 3
a) State the hypotheses for testing if the four
candies are uniformly distributed in the bag.
b) Check the conditions and calculate p-value.
Based on the p-value, what is your conclusion?

Brand Observed Expected (O E)2/E


Krackel 33 33 0.0000
Mr. Goodbar 32 33 0.0303
Milk Chocolate 37 33 0.4848
Dark Chocolate 30 33 0.2727
Total 132 132 0.7878
12
Example 4
A professor using an open source introductory
statistics book predicts that 60% of the students will
purchase a hard copy of the book, 25% will print it out
from the web, and 15% will read it online. At the end
of the semester he asks his students to complete a
survey where they indicate what format of the book
they used.
Of the 126 students, 71 said they bought a hard copy
of the book, 30 said they printed it out from the web,
and 25 said they read it online.

13
Example 4 continued
a) State the hypotheses for testing if the
professor's predictions were inaccurate.
b) How many students did the professor expect to
buy the book, print the book, and read the book
exclusively online?

Observed Expected
purchase a hard copy 71
print it out 30
read it online 25
Total 126
14
Example 4 continued
c) This is an appropriate setting for a chi-square
test. List the conditions required for a test and
verify they are satisfied.
d) Calculate the chi-squared statistic, the degrees
of freedom associated with it, and the p-value.

Observed Expected
purchase a hard copy 71 75.6
print it out 30 31.5
read it online 25 18.9
Total 126 126
15
Example 4 continued
e) Based on the p-value calculated in part (d),
what is the conclusion of the hypothesis test?
Interpret your conclusion in this context.

Observed Expected
purchase a hard copy 71
print it out 30
read it online 25
Total 126
16
Example 5
Absenteeism of college students from math classes is
a major concern to math instructors because missing
class appears to increase the drop rate. Three
statistics instructors wondered whether the absentee
rate was the same for every day of the school week.

Absences Observed Absences Expected


Monday 26
Tuesday 19
Wednesday 17
Thursday 18
Friday 40
Total 120 120 17
Example 5 continued
They took a sample of absent students from three of
their statistics classes during one week of the term.
The results of the survey appear in the table.
Run a goodness-of-fit test to determine if the absentee
rate is the same throughout the week.
Absences Observed Absences Expected
Monday 26
Tuesday 19
Wednesday 17
Thursday 18
Friday 40
Total 120 120 18
Example 6
Now remove Friday and rerun a goodness-of-fit test to
determine if the absentee rate is the same Monday
through Thursday.

Absences Observed Absences Expected


Monday 26
Tuesday 19
Wednesday 17
Thursday 18
Total 80 80
19

Potrebbero piacerti anche