A Bayesian 2 test for goodness of fit 10/23/09 Multilevel RIT.
2 as a test for goodness of fit
description
Transcript of 2 as a test for goodness of fit
![Page 1: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/1.jpg)
![Page 2: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/2.jpg)
2 as a test for goodness of fit
• So far. . . .
• The expected frequencies that we have calculated come from the data
• They test rather or not two variables are related
![Page 3: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/3.jpg)
2 as a test for goodness of fit
• But what if:
• You have a theory or hypothesis that the frequencies should occur in a particular manner?
![Page 4: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/4.jpg)
Example
• M&Ms claim that of their candies:• 30% are brown• 20% are red• 20% are yellow• 10% are blue• 10% are orange• 10% are green
![Page 5: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/5.jpg)
Example
• Based on genetic theory you hypothesize that in the population:
• 45% have brown eyes• 35% have blue eyes• 20% have another eye color
![Page 6: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/6.jpg)
To solve you use the same basic steps as before (slightly different order)
• 1) State the hypothesis• 2) Find 2 critical• 3) Create data table• 4) Calculate the expected frequencies• 5) Calculate 2
• 6) Decision• 7) Put answer into words
![Page 7: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/7.jpg)
Example• M&Ms claim that of their candies:
• 30% are brown• 20% are red• 20% are yellow• 10% are blue• 10% are orange• 10% are green
![Page 8: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/8.jpg)
Example
• Four 1-pound bags of plain M&Ms are purchased
• Each M&Ms is counted and categorized according to its color
• Question: Is M&Ms “theory” about the colors of M&Ms correct?
![Page 9: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/9.jpg)
Observed
Brown 602
Red 396
Yellow 379
Blue 227
Orange 242
Green 235
Total 2081
![Page 10: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/10.jpg)
Step 1: State the Hypothesis
• H0: The data do fit the model– i.e., the observed data does agree with M&M’s theory
• H1: The data do not fit the model– i.e., the observed data does not agree with M&M’s
theory
– NOTE: These are backwards from what you have done before
![Page 11: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/11.jpg)
Step 2: Find 2 critical
• df = number of categories - 1
![Page 12: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/12.jpg)
Step 2: Find 2 critical
• df = number of categories - 1
• df = 6 - 1 = 5• = .05
• 2 critical = 11.07
![Page 13: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/13.jpg)
Observed
Brown 602
Red 396
Yellow 379
Blue 227
Orange 242
Green 235
Total 2081
Step 3: Create the data table
![Page 14: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/14.jpg)
Observed ExpectedProp.
Brown 602 .30
Red 396 .20
Yellow 379 .20
Blue 227 .10
Orange 242 .10
Green 235 .10
Total 2081
Step 3: Create the data tableAdd the expected proportion of each category
![Page 15: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/15.jpg)
Observed ExpectedProp.
Brown 602 .30
Red 396 .20
Yellow 379 .20
Blue 227 .10
Orange 242 .10
Green 235 .10
Total 2081
Step 4: Calculate the Expected Frequencies
![Page 16: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/16.jpg)
Observed ExpectedProp.
ExpectedFreq
Brown 602 .30
Red 396 .20
Yellow 379 .20
Blue 227 .10
Orange 242 .10
Green 235 .10
Total 2081
Step 4: Calculate the Expected FrequenciesExpected Frequency = (proportion)(N)
![Page 17: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/17.jpg)
Observed ExpectedProp.
ExpectedFreq
Brown 602 .30 624.30
Red 396 .20
Yellow 379 .20
Blue 227 .10
Orange 242 .10
Green 235 .10
Total 2081
Step 4: Calculate the Expected FrequenciesExpected Frequency = (.30)(2081) = 624.30
![Page 18: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/18.jpg)
Observed ExpectedProp.
ExpectedFreq
Brown 602 .30 624.30
Red 396 .20 416.20
Yellow 379 .20
Blue 227 .10
Orange 242 .10
Green 235 .10
Total 2081
Step 4: Calculate the Expected FrequenciesExpected Frequency = (.20)(2081) = 416.20
![Page 19: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/19.jpg)
Observed ExpectedProp.
ExpectedFreq
Brown 602 .30 624.30
Red 396 .20 416.20
Yellow 379 .20 416.20
Blue 227 .10
Orange 242 .10
Green 235 .10
Total 2081
Step 4: Calculate the Expected FrequenciesExpected Frequency = (.20)(2081) = 416.20
![Page 20: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/20.jpg)
Observed ExpectedProp.
ExpectedFreq
Brown 602 .30 624.30
Red 396 .20 416.20
Yellow 379 .20 416.20
Blue 227 .10 208.10
Orange 242 .10 208.10
Green 235 .10 208.10
Total 2081
Step 4: Calculate the Expected FrequenciesExpected Frequency = (.10)(2081) = 208.10
![Page 21: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/21.jpg)
Step 5: Calculate 2
O = observed frequency
E = expected frequency
![Page 22: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/22.jpg)
2
O E O - E (O - E)2 (O - E)2
E
![Page 23: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/23.jpg)
2
O E O - E (O - E)2 (O - E)2
E602 624.30396 416.20379 416.20227 208.10242 208.10235 208.10
![Page 24: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/24.jpg)
2
O E O - E (O - E)2 (O - E)2
E602 624.30 -22.3396 416.20 -20.2379 416.20 -37.2227 208.10 18.9242 208.10 33.9235 208.10 26.9
![Page 25: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/25.jpg)
2
O E O - E (O - E)2 (O - E)2
E602 624.30 -22.3 497.29396 416.20 -20.2 408.04379 416.20 -37.2 1383.84227 208.10 18.9 357.21242 208.10 33.9 1149.21235 208.10 26.9 723.61
![Page 26: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/26.jpg)
2
O E O - E (O - E)2 (O - E)2
E602 624.30 -22.3 497.29 .80396 416.20 -20.2 408.04 .98379 416.20 -37.2 1383.84 3.32227 208.10 18.9 357.21 1.72242 208.10 33.9 1149.21 5.22235 208.10 26.9 723.61 3.48
![Page 27: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/27.jpg)
2
O E O - E (O - E)2 (O - E)2
E602 624.30 -22.3 497.29 .80396 416.20 -20.2 408.04 .98379 416.20 -37.2 1383.84 3.32227 208.10 18.9 357.21 1.72242 208.10 33.9 1149.21 5.22235 208.10 26.9 723.61 3.48
15.52
![Page 28: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/28.jpg)
Step 6: Decision
• Thus, if 2 > than 2critical
– Reject H0, and accept H1
• If 2 < or = to 2critical
– Fail to reject H0
![Page 29: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/29.jpg)
Step 6: Decision
• Thus, if 2 > than 2critical
– Reject H0, and accept H1
• If 2 < or = to 2critical
– Fail to reject H0
2 = 15.52
2 crit = 11.07
![Page 30: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/30.jpg)
Step 7: Put answer into words
• H1: The data do not fit the model
• M&M’s color “theory” did not significantly (.05) fit the data
![Page 31: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/31.jpg)
![Page 32: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/32.jpg)
Practice• Among women in the general population under
the age of 40:
• 60% are married• 23% are single• 4% are separated• 12% are divorced• 1% are widowed
![Page 33: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/33.jpg)
Practice
• You sample 200 female executives under the age of 40
• Question: Is marital status distributed the same way in the population of female executives as in the general population ( = .05)?
![Page 34: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/34.jpg)
Observed
Married 100
Single 44
Separated 16
Divorced 36
Widowed 4
Total 200
![Page 35: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/35.jpg)
Step 1: State the Hypothesis
• H0: The data do fit the model– i.e., marital status is distributed the same way in the
population of female executives as in the general population
• H1: The data do not fit the model– i.e., marital status is not distributed the same way in
the population of female executives as in the general population
![Page 36: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/36.jpg)
Step 2: Find 2 critical
• df = number of categories - 1
![Page 37: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/37.jpg)
Step 2: Find 2 critical
• df = number of categories - 1
• df = 5 - 1 = 4• = .05
• 2 critical = 9.49
![Page 38: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/38.jpg)
Step 3: Create the data table
Observed ExpectedProp.
Married 100 .60
Single 44 .23
Separated 16 .04
Divorced 36 .12
Widowed 4 .01
Total 200
![Page 39: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/39.jpg)
Step 4: Calculate the Expected Frequencies
Observed ExpectedProp.
ExpectedFreq.
Married 100 .60 120
Single 44 .23 46
Separated 16 .04 8
Divorced 36 .12 24
Widowed 4 .01 2
Total 200
![Page 40: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/40.jpg)
Step 5: Calculate 2
O = observed frequency
E = expected frequency
![Page 41: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/41.jpg)
2
O E O - E (O - E)2 (O - E)2
E100 120 -20 400 3.3344 46 -2 4 .0916 8 8 64 836 24 12 144 64 2 2 4 2
19.42
![Page 42: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/42.jpg)
Step 6: Decision
• Thus, if 2 > than 2critical
– Reject H0, and accept H1
• If 2 < or = to 2critical
– Fail to reject H0
![Page 43: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/43.jpg)
Step 6: Decision
• Thus, if 2 > than 2critical
– Reject H0, and accept H1
• If 2 < or = to 2critical
– Fail to reject H0
2 = 19.42
2 crit = 9.49
![Page 44: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/44.jpg)
Step 7: Put answer into words
• H1: The data do not fit the model
• Marital status is not distributed the same way in the population of female executives as in the general population ( = .05)
![Page 45: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/45.jpg)
![Page 46: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/46.jpg)
Practice• Is there a significant ( = .05) relationship
between gender and a persons favorite Thanksgiving “side” dish?
• Each participant reported his or her most favorite dish.
![Page 47: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/47.jpg)
Results
Sweet Potatoes
Stuffing Cranberries
Female 18 10 2
Male 22 50 18
Side Dish
Gend
er
![Page 48: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/48.jpg)
Step 1: State the Hypothesis
• H1: There is a relationship between gender and favorite side dish
• Gender and favorite side dish are independent of each other
![Page 49: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/49.jpg)
Step 3: Find 2 critical
• df = (R - 1)(C - 1)
• df = (2 - 1)(3 - 1) = 2• = .05
• 2 critical = 5.99
![Page 50: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/50.jpg)
Results
Sweet Potatoes
Stuffing Cranberries
Female 18 (10)
10 (15)
2 (5)
Male 22 (30)
50 (45)
18 (15)
Side Dish
Gend
er
![Page 51: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/51.jpg)
Step 5: Calculate 2
O E O - E (O - E)2 (O - E)2
E 18 10 8 64 6.4 10 15 -5 25 1.67 2 5 -3 9 1.8
22 30 -8 64 2.13 50 45 5 25 .55 18 15 3 9 .6
2 = 13.15
![Page 52: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/52.jpg)
Step 6: Decision
• Thus, if 2 > than 2critical
– Reject H0, and accept H1
• If 2 < or = to 2critical
– Fail to reject H0
![Page 53: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/53.jpg)
Step 6: Decision
• Thus, if 2 > than 2critical
– Reject H0, and accept H1
• If 2 < or = to 2critical
– Fail to reject H0
2 = 13.15
2 crit = 5.99
![Page 54: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/54.jpg)
Step 7: Put answer into words
• H1: There is a relationship between gender and favorite side dish
• A person’s favorite Thanksgiving side dish is significantly (.05) related to their gender
![Page 55: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/55.jpg)
Practice• As part of a program to reducing smoking, a
national organization ran an advertising campaign to convince people to quit or reduce their smoking. To evaluate the effectiveness of their campaign, they had 15 subjects record the average number of cigarettes smoked per day in the week before and the week after exposure to the advertisement. Determine if the advertisements reduced their smoking (Alpha = .05).
![Page 56: 2 as a test for goodness of fit](https://reader035.fdocuments.us/reader035/viewer/2022062810/56815b99550346895dc9a03c/html5/thumbnails/56.jpg)
PracticeSubject Before After
1 45 43
2 16 20
3 20 17
4 33 30
5 30 25
6 19 19
7 33 34
8 25 28
9 26 23
10 40 41
11 28 26
12 36 40
13 15 16
14 26 23
15 32 34