Download presentation
Presentation is loading. Please wait.
Published byMadeleine Anderson Modified over 6 years ago
1
Lecture 36 Section 14.1 – 14.3 Mon, Nov 27, 2006
Test of Goodness of Fit Lecture 36 Section 14.1 – 14.3 Mon, Nov 27, 2006
2
Count Data Count data – Data that counts the number of observations that fall into each of several categories. The data may be univariate or bivariate. Univariate example – Observe a person’s opinion on a subject (strongly agree, agree, etc.). Bivariate example – Observe a opinion on a subject and their education level (< high school, high school, etc.)
3
Univariate Example Observe a person’s opinion on a question.
Strongly Agree Agree Neutral Disagree Strongly Disagree 100 120 80 50
4
Bivariate Example Observe students’ final grade in statistics and year in college. Strongly Agree Agree Neutral Disagree Strongly Disagree < High School 35 25 30 5 High School 40 15 10 College 20 > College
5
Observed and Expected Counts
Observed counts – The counts that were actually observed in the sample. Expected counts – The counts that would be expected if the null hypothesis were true.
6
Tests of Goodness of Fit
The goodness-of-fit test applies only to univariate data. The null hypothesis specifies a discrete distribution for the population. We want to determine whether a sample from that population supports this hypothesis.
7
Examples If we rolled a die 60 times, we expect 10 of each number.
If we get frequencies 8, 10, 14, 12, 9, 7, does that indicate that the die is not fair? If we toss a fair coin, we should get two heads ¼ of the time, two tails ¼ of the time, and one of each ½ of the time. Suppose we toss a coin 100 times and get two heads 16 times, two tails 36 times, and one of each 48 times. Is the coin fair?
8
Examples If we selected 20 people from a group that was 60% male and 40% female, we would expect to get 12 males and 8 females. If we got 15 males and 5 females, would that indicate that our selection procedure was not random (i.e., discriminatory)? What if we selected 100 people from the group and got 75 males and 25 females?
9
Null Hypothesis The null hypothesis specifies the probability (or proportion) for each category. In other words, it specifies a discrete probability distribution. Each probability is the probability that a random observation would fall into that category.
10
Null Hypothesis To test a die for fairness, the null hypothesis would be H0: p1 = 1/6, p2 = 1/6, …, p6 = 1/6. The alternative hypothesis will always be a simple negation of H0: H1: At least one of the probabilities is not 1/6. or more simply, H1: H0 is false.
11
Expected Counts To find the expected counts, we apply the hypothetical (H0) probabilities to the sample size. For example, if the hypothetical probabilities are 1/6 and the sample size is 60, then the expected counts are (1/6) 60 = 10.
12
Example We will use the sample data given for 60 rolls of a die to calculate the 2 statistic. Make a chart showing both the observed and expected counts (in parentheses). 1 2 3 4 5 6 8 (10) 10 14 12 9 7
13
The Chi-Square Statistic
Denote the observed counts by O and the expected counts by E. Define the chi-square (2) statistic to be Clearly, if the observed counts are close to the expected counts, then 2 will be small. But if even a few observed counts are far from the expected counts, then 2 will be large.
14
Chi-Square Degrees of Freedom
The chi-square distribution has an associated degrees of freedom, just like the t distribution. Each chi-square distribution has a slightly different shape, depending on the number of degrees of freedom.
15
Chi-Square Degrees of Freedom
16
Chi-Square Degrees of Freedom
2(2)
17
Chi-Square Degrees of Freedom
2(2) 2(5)
18
Chi-Square Degrees of Freedom
2(2) 2(5) 2(10)
19
Properties of 2 The chi-square distribution with df degrees of freedom has the following properties. 2 0. It is unimodal. It is skewed right (not symmetric!) 2 = df. 2 = (2df). If df is large, then 2(df) is approximately N(df, (2df)).
20
Chi-Square vs. Normal
21
Chi-Square vs. Normal 2(128)
22
Chi-Square vs. Normal 2(128) N(128, 16)
23
The Chi-Square Table See page A-11.
The left column is degrees of freedom: 1, 2, 3, …, 15, 16, 18, 20, 24, 30, 40, 60, 120. The column headings represent areas of lower tails: 0.005, 0.01, 0.025, 0.05, 0.10, 0.90, 0.95, 0.975, 0.99, Of course, the lower tails 0.90, 0.95, 0.975, 0.99, are the same as the upper tails 0.10, 0.05, 0.025, 0.01,
24
Example If df = 10, what value of 2 cuts off an lower tail of 0.05?
If df = 10, what value of 2 cuts off a upper tail of 0.05?
25
TI-83 – Chi-Square Probabilities
To find a chi-square probability (p-value) on the TI-83, Press DISTR. Select 2cdf (item #7). Press ENTER. Enter the lower endpoint, the upper endpoint, and the degrees of freedom. The probability appears.
26
Example Now calculate 2.
27
Computing the p-value The number of degrees of freedom is 1 less than the number of categories in the table. In this example, df = 5. To find the p-value, use the TI-83 to calculate the probability that 2(5) would be at least as large as 3.4. p-value = 2cdf(3.4, E99, 5) = Therefore, p-value = (accept H0).
28
The Effect of the Sample Size
What if the previous sample distribution persisted in a much larger sample, say n = 600? Would it be significant? 1 2 3 4 5 6 80 (100) 100 140 120 90 70
29
TI-83 – Goodness of Fit Test
The TI-83 will not automatically do a goodness-of-fit test. The following procedure will compute 2. Enter the observed counts into list L1. Enter the expected counts into list L2. Evaluate the expression (L1 – L2)2/L2. Select LIST > MATH > sum and apply the sum function to the previous result, i.e., sum(Ans). The result is the value of 2.
30
The List of Expected Counts
To get the list of expected counts, you may Store the list of hypothetical probabilities in L3. Multiply L3 by the sample size and store in L2. For example, if the probabilities for 6 categories are p1 = 1/6 , p2 = 1/6, p3 = 1/6 , p4 = 1/6, p5 = 1/6, and p6 = 1/6, and the sample size is n = 60, then Store {1/6,1/6,1/6,1/6,1/6,1/6} in L3. Compute L3*60 and store in L2.
31
Example To test whether the coin is fair, the null hypothesis would be
H0: pHH = 1/4, pTT = 1/4, pHT = 1/2. The alternative hypothesis would be H1: H0 is false. Let = 0.05.
32
Expected Counts To find the expected counts, we apply the hypothetical probabilities to the sample size. Expected HH = (1/4) 100 = 25. Expected TT = (1/4) 100 = 25. Expected HT = (1/2) 100 = 50.
33
Example We will use the sample data given for 60 rolls of a die to calculate the 2 statistic. Make a chart showing both the observed and expected counts (in parentheses). HH TT HT 16 (25) 36 48 (50)
34
Example Now calculate 2.
35
Compute the p-value In this example, df = 2.
To find the p-value, use the TI-83 to calculate the probability that 2(2) would be at least as large as 8.16. 2cdf(8.16, E99, 2) = Therefore, p-value = (reject H0). The coin appears to be unfair.
36
Example Suppose we select 20 people from a group that is 60% male and 40% female and we get 15 males and 5 females. Is it reasonable to believe that we selected the 20 people at random?
37
The Hypotheses To test that the process was random, the null hypothesis would be H0: pM = 0.60, pF = 0.40. The alternative hypothesis would be H1: H0 is false. Let = 0.05.
38
Calculate the Expected Counts
To find the expected counts, multiply the hypothetical probabilities to the sample size. Expected no. of males = 0.60 20 = 12. Expected no. of females = 0.40 20 = 8.
39
Make the Chart Make a chart showing both the observed and expected counts (in parentheses). M F 15 (12) 5 (8)
40
Compute 2 Now calculate 2.
41
Compute the p-value In this example, df = 1.
To find the p-value, use the TI-83 to calculate the probability that 2(1) would be at least as large as 2cdf(1.875, E99, 1) = Therefore, p-value = (accept H0). There is no evidence that the people were not selected at random.
42
Increase the Sample Size
Repeat the previous problem with a sample of 75 males and 25 females.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.