Presentation is loading. Please wait.

Presentation is loading. Please wait.

The χ 2 (Chi-Squared) Test. Crazy Dice? You roll a die 60 times and get: 3 ones, 6 twos, 19 threes, 22 fours, 6 fives, and 4 sixes  Is this a fair die?

Similar presentations


Presentation on theme: "The χ 2 (Chi-Squared) Test. Crazy Dice? You roll a die 60 times and get: 3 ones, 6 twos, 19 threes, 22 fours, 6 fives, and 4 sixes  Is this a fair die?"— Presentation transcript:

1 The χ 2 (Chi-Squared) Test

2 Crazy Dice? You roll a die 60 times and get: 3 ones, 6 twos, 19 threes, 22 fours, 6 fives, and 4 sixes  Is this a fair die? How could we test this to prove it?  Not a mean number of anything  Six proportions to test!

3 Chi-Squared Test countsTests counts of categorical data Does observed data match what we expect to happen? Three types of χ 2 tests: –Goodness of Fit (one variable) –Independence (two variables) –Homogeneity (one variable from two different samples)

4 χ 2 Distribution df = 3 df = 5 df = 10

5 χ 2 Distribution Different df = different curves Skewed right normalAs df increase, curve shifts right & becomes more normal

6 χ 2 Conditions ReasonablyReasonably random sample CountsCounts of categorical data; we expect each category to happen at least once Sample sizeSample size must be large enough  we expect at least five in each category ***Be sure to list expected counts! Combine these together: All expected counts are at least 5

7 χ 2 Formula

8 χ 2 Goodness of Fit Test Univariate data How well do observed counts “fit” what we expect the counts to be? χ 2 cdfUse χ 2 cdf to find p-values categoriesdf = number of categories – 1

9 Hypotheses: Written in words! H 0 : The data fits what we expect H a : The data doesn't fit what we expect (In context!)

10 Does your zodiac sign determine how successful you will be? Fortune magazine collected the zodiac signs of 256 heads of the largest 400 companies. Is there sufficient evidence to suggest successful people are more likely to be born under some signs than others? Aries 23Libra18Leo20 Taurus20Scorpio21Virgo19 Gemini18Sagittarius19Aquarius24 Cancer23Capricorn22Pisces29 How many would you expect in each sign if there were no difference between them? How many degrees of freedom? We expect CEOs to be born equally under all signs: 256/12 = 21.333333 Since there are 12 signs, df = 12 – 1 = 11

11 Conditions: Reasonably random sample All expected counts (21.33) > 5 H 0 : The same number of CEO’s are born under each sign. H a : More CEO’s are born under some signs than others. p-value = χ 2 cdf(5.094, 10^99, 11) =.9265 α =.05 Since p-value > α, we fail to reject H 0. There is not sufficient evidence to suggest that more CEOs are born under some signs than others.

12 A company says its premium mixture of nuts contains 10% Brazil nuts, 20% cashews, 20% almonds, 10% hazelnuts, and 40% peanuts. You buy a large can and separate the nuts. Upon weighing them, you find there are 112g of Brazil nuts, 183g of cashews, 207g of almonds, 71g of hazelnuts, and 446g of peanuts. You wonder: Is your mix significantly different from what the company advertises? Why is the chi-squared goodness-of-fit test NOT appropriate here? What could we do to use chi-squared? The can has 300 total nuts. What are the expected counts of each type of nut? counts We don't have counts of nuts Count Count the nuts instead of weighing them TypeBrazilCashewAlmondHazelnutPeanut Exp. Count3060 30120

13 Offspring of certain fruit flies may have yellow or ebony bodies and normal wings or short wings. Genetic theory predicts that these traits will appear in the ratio 9:3:3:1 (yellow & normal, yellow & short, ebony & normal, ebony & short). A researcher checks 100 such flies and finds the distribution of traits to be 59, 20, 11, and 10, respectively. What are the expected counts? df? Expected counts: Y & N = 56.25 Y & S = 18.75 E & N = 18.75 E & S = 6.25 9 + 3 + 3 + 1 = 16 So we expect 9/16 to be Y & N, 3/16 to be Y & S, 3/16 to be E & N, and 1/16 to be E & S 4 categories  df = 4 – 1 = 3

14 Are the results consistent with the genetic model's predictions? Conditions: Reasonably random sample All expected counts > 5 (Y/N = 56.25, Y/S = 18.75, E/N = 18.75, E/S = 6.25) H 0 : The distribution of flies is the same as the genetic model. H a : The distribution of flies is different from the genetic model. p-value = χ 2 cdf(5.671, 10^99, 3) =.129α =.05 Since p-value > α, we fail to reject H 0. There is not sufficient evidence to suggest that the distribution of fruit flies is different from the genetic model.

15 χ 2 Test for Independence Bivariate data from one sample Are two categorical variables dependent or independent? χ 2 -TestUse χ 2 -Test to find p-values

16 Same conditions and formula!

17 Hypotheses: Written in words! H 0 : The variables are independent H a : The variables are dependent (In context!)

18 A beef distributor wants to determine whether there is a relationship between geographic region and preferred cut of meat. If there is no relationship, we will say that beef preference is independent of geographic region. Suppose that, in a random sample of 500 customers, 300 are from the North and 200 from the South. Also, 150 prefer cut A, 275 prefer cut B, and 75 prefer cut C.

19 If beef preference is independent of geographic region, how would we expect this table to be filled in? NorthSouthTotal Cut A150 Cut B275 Cut C75 Total300200500 9060 165110 4530

20 Expected Counts Assuming H 0 is true,

21 Degrees of Freedom Or: 1. Cover up one row & one column 2. Count the number of cells remaining

22 In the actual sample of 500 consumers, the observed counts were as follows: Is there sufficient evidence to suggest that geographic regions and beef preference are not independent? NorthSouthTotal Cut A10050150 Cut B150125275 Cut C502575 Total300200500

23 Conditions: Reasonably random sample All expected counts > 5 H 0 : Geographic region and beef preference are independent H a : Geographic region and beef preference are dependent p-value =.0226 α =.05 Since p-value < α, we reject H 0. There is sufficient evidence to suggest that geographic region and beef preference are dependent. Expected Counts:N S A90 60 B165110 C45 30

24 χ 2 Test for Homogeneity One categoricaltwo (or more) independent samplesOne categorical variable from two (or more) independent samples Are the two populations the same (homogeneous)? χ 2 -TestUse χ 2 -Test to find p-values

25 Conditions: THE SAME! Formula: THE SAME! Expected counts & df: THE SAME AS INDEPENDENCE! Only Only change? Hypotheses!

26 Hypotheses: Written in words! H 0 : The distributions are the same H a : The distributions are different (In context!)

27 The following data is on drinks per week for independently chosen random samples of male and female students. (low = 1-7, moderate = 8- 24, high = 25 or more) Does there appear to be a gender difference with respect to drinking behavior? MenWomenTotal None140186326 Low4786611139 Moderate300173473 High631679 Total98110362017

28 Conditions: Reasonably random samples All expected counts > 5 H 0 : Drinking behavior is the same for men & women H a : Drinking behavior is not the same for men & women p-value = 0 α =.05 Since p-value < α, we reject H 0. There is sufficient evidence to suggest drinking behavior is not the same for men & women. Expected Counts: Men Women None158.6167.4 Low554.0585.0 Mod230.1243.0 High38.440.6


Download ppt "The χ 2 (Chi-Squared) Test. Crazy Dice? You roll a die 60 times and get: 3 ones, 6 twos, 19 threes, 22 fours, 6 fives, and 4 sixes  Is this a fair die?"

Similar presentations


Ads by Google