12.2: A Goodness-of-Fit Test
- Page ID
- 26117
In this type of hypothesis test, you determine whether the data "fit" a particular distribution or not. For example, you may suspect your unknown data fit a binomial distribution. You use a chi-square test (meaning the distribution for the hypothesis test is chi-square) to determine if there is a fit or not. The null and the alternative hypotheses for this test may be written in sentences or may be stated as equations or inequalities.
The test statistic for a goodness-of-fit test is:
where:
- \(O =\) observed values (data)
- \(E =\) expected values (from theory)
- \(k =\) the number of different data cells or categories
The observed values are the data values and the expected values are the values you would expect to get if the null hypothesis were true. There are \(n\) terms of the form \(\frac{(O - E)^{2}}{E}\).
The number of degrees of freedom is \(df = (\text{number of categories} - 1)\).
The goodness-of-fit test is almost always right-tailed. If the observed values and the corresponding expected values are not close to each other, then the test statistic can get very large and will be way out in the right tail of the chi-square curve.
The expected value for each cell needs to be at least five in order for you to use this test.
Example 11.3.1
Absenteeism of college students from math classes is a major concern to math instructors because missing class appears to increase the drop rate. Suppose that a study was done to determine if the actual student absenteeism rate follows faculty perception. The faculty expected that a group of 100 students would miss class according to Table.
Number of absences per term | Expected number of students |
---|---|
0–2 | 50 |
3–5 | 30 |
6–8 | 12 |
9–11 | 6 |
12+ | 2 |
A random survey across all mathematics courses was then done to determine the actual number (observed) of absences in a course. The chart in Table displays the results of that survey.
Number of absences per term | Actual number of students |
---|---|
0–2 | 35 |
3–5 | 40 |
6–8 | 20 |
9–11 | 1 |
12+ | 4 |
Determine the null and alternative hypotheses needed to conduct a goodness-of-fit test.
- \(H_{0}\): Student absenteeism fits faculty perception.
- \(H_{a}\): Student absenteeism does not fit faculty perception.
Example 11.3.2
Employers want to know which days of the week employees are absent in a five-day work week. Most employers would like to believe that employees are absent equally during the week. Suppose a random sample of 60 managers were asked on which day of the week they had the highest number of employee absences. The results were distributed as in Table. For the population of employees, do the days for the highest number of absences occur with equal frequencies during a five-day work week? Test at a 5% significance level.
Monday | Tuesday | Wednesday | Thursday | Friday | |
---|---|---|---|---|---|
Number of Absences | 15 | 12 | 9 | 9 | 15 |
Answer
The null and alternative hypotheses are:
- \(H_{0}\): The absent days occur with equal frequencies, that is, they fit a uniform distribution.
- \(H_{a}\): The absent days occur with unequal frequencies, that is, they do not fit a uniform distribution.
If the absent days occur with equal frequencies, then, out of 60 absent days (the total in the sample: \(15 + 12 + 9 + 9 + 15 = 60\)), there would be 12 absences on Monday, 12 on Tuesday, 12 on Wednesday, 12 on Thursday, and 12 on Friday. These numbers are the expected (\(E\)) values. The values in the table are the observed (\(O\)) values or data.
This time, calculate the \(\chi^{2}\) test statistic by hand. Make a chart with the following headings and fill in the columns:
- Expected (\(E\)) values \((12, 12, 12, 12, 12)\)
- Observed (\(O\)) values \((15, 12, 9, 9, 15)\)
- \((O – E)\)
- \((O – E)^{2}\)
- \(\frac{(O - E)^{2}}{E}\)
Now add (sum) the last column. The sum is three. This is the \(\chi^{2}\) test statistic.
To find the p-value, calculate \(P(\chi^{2} > 3)\). This test is right-tailed. (Use a computer or calculator to find the p-value. You should get \(p\text{-value} = 0.5578\).)
The \(dfs\) are the \(\text{number of cells} - 1 = 5 - 1 = 4\)
Press 2nd DISTR
. Arrow down to \(\chi^{2}\)cdf. Press ENTER
. Enter(3,10^99,4)
. Rounded to four decimal places, you should see 0.5578, which is the \(p\text{-value}\).
Next, complete a graph like the following one with the proper labeling and shading. (You should shade the right tail.)
The decision is not to reject the null hypothesis.
Conclusion: At a 5% level of significance, from the sample data, there is not sufficient evidence to conclude that the absent days do not occur with equal frequencies.
Example 11.3.4
Suppose you flip two coins 100 times. The results are 20 HH, 27 HT, 30 TH, and 23 TT. Are the coins fair? Test at a 5% significance level.
Answer
This problem can be set up as a goodness-of-fit problem. The sample space for flipping two fair coins is \({HH, HT, TH, TT}\). Out of 100 flips, you would expect 25 HH, 25 HT, 25 TH, and 25 TT. This is the expected distribution. The question, "Are the coins fair?" is the same as saying, "Does the distribution of the coins (\(20 HH, 27 HT, 30 TH, 23 TT\)) fit the expected distribution?"
Random Variable: Let \(X =\) the number of heads in one flip of the two coins. \(X\) takes on the values 0, 1, 2. (There are 0, 1, or 2 heads in the flip of two coins.) Therefore, the number of cells is three. Since \(X =\) the number of heads, the observed frequencies are 20 (for two heads), 57 (for one head), and 23 (for zero heads or both tails). The expected frequencies are 25 (for two heads), 50 (for one head), and 25 (for zero heads or both tails). This test is right-tailed.
\(H_{0}\): The coins are fair.
\(H_{a}\): The coins are not fair.
Distribution for the test: \(\chi^{2}_{2}\) where \(df = 3 - 1 = 2\).
Calculate the test statistic: \(\chi^{2} = 2.14\)
Graph:
Probability statement: \(p\text{-value} = P(\chi^{2} > 2.14) = 0.3430\)
Compare α and the p-value:
\(\alpha = 0.05\)
\(p\text{-value} = 0.3430\)
\(\alpha < p\text{-value}\).Make a decision: Since \(\alpha < p\text{-value}\), do not reject \(H_{0}\).
Conclusion: There is insufficient evidence to conclude that the coins are not fair.
WeBWorK Problems
Query \(\PageIndex{1}\)
Query \(\PageIndex{2}\)
References
- Data from the U.S. Census Bureau
- Data from the College Board. Available online at http://www.collegeboard.com.
- Data from the U.S. Census Bureau, Current Population Reports.
- Ma, Y., E.R. Bertone, E.J. Stanek III, G.W. Reed, J.R. Hebert, N.L. Cohen, P.A. Merriam, I.S. Ockene, “Association between Eating Patterns and Obesity in a Free-living US Adult Population.” American Journal of Epidemiology volume 158, no. 1, pages 85-92.
- Ogden, Cynthia L., Margaret D. Carroll, Brian K. Kit, Katherine M. Flegal, “Prevalence of Obesity in the United States, 2009–2010.” NCHS Data Brief no. 82, January 2012. Available online at http://www.cdc.gov/nchs/data/databriefs/db82.pdf (accessed May 24, 2013).
- Stevens, Barbara J., “Multi-family and Commercial Solid Waste and Recycling Survey.” Arlington Count, VA. Available online at www.arlingtonva.us/department.../file84429.pdf (accessed May 24,2013).
Review
To assess whether a data set fits a specific distribution, you can apply the goodness-of-fit hypothesis test that uses the chi-square distribution. The null hypothesis for this test states that the data come from the assumed distribution. The test compares observed values against the values you would expect to have if your data followed the assumed distribution. The test is almost always right-tailed. Each observation or cell category must have an expected value of at least five.
Formula Review
\(\sum_k \frac{(O - E)^{2}}{E}\) goodness-of-fit test statistic where:
\(O\): observed values
\(E\): expected value
\(k\): number of different data cells or categories
\(df = k - 1\) degrees of freedom