the practice of statistics third edition chapter 14: inference for distributions of categorical...

Download The Practice of Statistics Third Edition Chapter 14: Inference for Distributions of Categorical Variables: Chi-Square Procedures Copyright © 2008 by W

If you can't read please download the document

Upload: christina-sherman

Post on 18-Jan-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

The Practice of Statistics Third Edition Chapter 14: Inference for Distributions of Categorical Variables: Chi-Square Procedures Copyright 2008 by W. H. Freeman & Company Daniel S. Yates The chi-square procedure for goodness of fit allows us to determine whether a specified population distribution seems valid. We can compare two or more population proportions using a chi-square test for homogeneity of populations. The chi-square test of association/independence helps us decide whether the distribution of one variable has been influenced by another variable. Are you more likely to have an auto wreck when using a cell phone? Does background music influence wine purchases? How does the presence of an exclusive-territory clause in a franchisees contract relate to the success of the business? Suppose in your bag of 56 M&Ms there are only 2 red M&Ms. Knowing that 13% of all M&Ms are red, and you only have 3.6% reds, you might think that you did not get your fair share of M&Ms. The chi-squared ( 2 ) test for goodness of fit is a single test that can be applied to see if the observed sample distribution is significantly different in some way from the hypothetical population distribution. Are you more likely to have an accident when using a cell phone? A study of 699 drivers who were using aa cell phone when they had an accident examined this question. These drivers made 26,798 cell phone calls during a 14 month period. Each of the 699 collisions was classified in various ways. Here are the counts for each day of the week. DayMonTuesWedThursFriSatSunTotal Number We can think of this table as a one-way table with seven cells each with a count of the number of accidents that occurred on that particular day of the week. H o : Motor vehicle accidents involving cell phones are equally likely to occur on any day of the week. H a : The probability of accidents involving cell phone use vary with the day of the week We can also state the hypotheses in terms of population proportions. H 0 : P Sunday =P monday =.=P saturday =1/7 H a : At least one of the populations differs from the stated value. To determine whether the distribution of accidents is uniform, we need a way to measure how well the observed counts (O) fit the expected counts (E) under H 0 X 2 is called the Chi-square statistic DayObserved count (o)Expected Count (E)(O-E) 2 /E Sunday Monday Tuesday Wednesday Thursday Friday Saturday X 2 =208.84 In Table D, for a P-value of , we find the critical value to be Since our X 2 = is more extreme (larger) than the critical value, we say the probability of observing a result as extreme as the one we did is by chance alone is less than 0.05 %. There is sufficient evidence to reject H 0 and conclude that these types of accidents are not equally likely to occur on each of the seven days of the week. In checking conditions, remember that its expected counts that are critical not the observed counts. 1. The total area under the curve is equal to Each Chi-square curve begins at 0 on the horizontal axis, increasing to a peak, then approaches the horizontal axis asymptotically from above. 3. Each chi-square curve is skewed to the right. As the number of degrees of freedom increases, the curve becomes more and more symmetrical and looks more like a normal curve. The following Punnett square shows the possible gene combinations for fruit flies from parents with RrCc genes for eye color and wing type. RCRcrCrc RCRRCCRRCcRrCCRrCc RcRRCcRRccRrCcRrcc rCrrCc rrCCrrCc rcRrCcRrccrrCcrrcc The biologists are interested in the proportions of offspring that fall in each genetic category for the population of all fruit flies that would result from crossing two parents RrCc. We can use a chi-square measure of goodness of fit test to measure the strength of the evidence against the hypothesized distribution, provided that the expected cell counts are large enough. Red eye straight wing(200)(0.5625)=112.5 Red eye curly wing(200)(0.1875)=37.5 White eye straight wing(200)(0.1875)=37.5 White eye, curly wing(200)(0.0625)=12.5 All are greater than 5. The test statistic is for df=4-1Technology produces the actual value of The P-value of indicates that the probability of obtaining a sample of 200 fruit fly offspring in which the proportions differ from the hypothetical values by at least as much as the ones in our sample is over 10%, assuming that the null hypothesis is true. This is not sufficient evidence to reject the biologists predicted distribution. Use the technology tool box on p to find goodness of fit on your calculator. p , 13.3 What if we want to compare more than two groups. We need a new test that begins with putting information into a two way table. The same test that compares several proportions, also determines whether the row and column variables are related in any two- way table. WineNoneFrenchItalianTotal French Italian Other Total __________ ___Music_______________ WineNoneFrenchItalianTotal French Italian Other Total100.0 Column Percents for Wine and Music _________Music______________ There appears to be an association between the music played and the type of wine customers buy. Sales of Italian wine are low when French music is playing, but are higher when Italian music or no music is playing. French wine sells well under all conditions but notably better when French music is playing. We could do three tests comparing no music to Italian music, no music to French Music, and French Music to Italian Music. The weakness of doing three test is that we get three different results. The problem of how to do many comparisons at once with some overall measure of confidence in all our conclusions is the problem of multiple comparisons. 1. An overall test to see if there is good evidence of any difference among the parameters we want to compare. 2. A detailed follow-up analysis to decide which of the parameters differ and to estimate how large the differences are. The overall test is the X 2 test but in this new setting it will be used for comparing several population proportions. A two-way table gives counts for both successes and failures. A table with r rows and c columns is an r X c table. The r X c table allows us to compare more than two populations, more than two categories of response, or both. In this setting, the null hypothesis becomes H o : The distribution of the response variable is the same in all c populations Population 1: bottles of wine sold when no music is playing Population 2: bottles of wine sold when French music is playing Population 3: bottles of wine sold when Italian music is playing. H o : The proportion of each wine type sold are the same in all populations. The parameters of the model are the proportion of the three types of wine that would be sold in each environment. WineNoneFrenchItalianTotal French Italian Other Total We will find the expected count for the cell in row1, column 1 If H 0 is true, we expect the same proportions for all three groups. The expected count of n o music among the 99 subjects who order French wine is The expected count has the form announced in the box: Calculate the expected count for the remaining cells in the same way, Expected Counts for Music and Wine Music WineNoneFrenchItalianTotal French , Italian Other Total Note that although any count of bottles of wine sold must be a whole number, an expected count need not be. p , 13.11, 13.14, 13.15 We must calculate the X 2 statistic for each cell and then sum over all nine cells. For French wine with no music As in the test of goodness of fit, The X 2 statistic is a measure of the distance observed counts from expected counts. Although the alternative hypothesis is many-sided, the Chi- square test is one-sided because any violation of the null Hypothesis tends to produce a large X 2 value. Small values are not evidence against H 0. Step1: Population and parameters We want to use X 2 to compare the distribution of types of wine selected for each type of music. Our hypotheses are H o : The distributions of wine selected are the same in all three populations of music types. H o : The distributions of wine selected are not all the same. To use the Chi square test for homogeneity of populations: The data must come from independent SRSs from the population of interest. We are willing to treat the subjects in the three groups as SRSs from their respective pop ulations. All expected cell counts are greater than or equal to 5. The test statistic is Because there are r=3 types of wine and c=3 music conditions, the degrees of freedom are: df=(r-1)(c-1)=(3-1)(3-1)=4 To obtain the p-value Use table D at the df =4 row and lies between the row and the row. So P lies in between and Because the expected cell counts are all large, the P-value from table D will be quite accurate. There is strong evidence to reject H o and conclude that the type of music being played has significant effect on wine sales. First, the size and nature of the relationship between music and wine sales are described by row and column percents. Italian wine sells poorly when French music is played. French music sells well across the board but better when French music is played. Second, Compare the observed and expected counts Third, Minitab prints under the table the 9 individual distances between the observed and expected counts that add to give you X 2. These are Components of X 2. The largest show which cell contributes most to X 2. Looking at the table, we see that just two cells contribute about 77% of the total X 2. Comparing these cells, we see that Italian wine sales are much below the expected count when French music is played, and well above the expected count when Italian music is played. We are led to the conclusion that Italian wine sales are strongly affected by Italian and French music. The Chi-square test does not in itself tell us what population our conclusion describes. For a r X 2 table, The Chi-square statistic is just the square of the z-statistic, and the p-value for X 2 is exactly the same as the two-sided P-value for z. We recommend using the z test to compare two proportions because it gives you the choice of a one-sided test and is related to the confidence interval. SuccessYesNototal Yes No Total Observed number of firms Exclusive Territories How does the presence of an exclusive territory clause relate to the survival of a business? A study to address this question collected data from 170 new franchise firms. This two-way table does not compare several populations, instead it arises by classifying observations from a single population in two ways: by exclusive territory and success. Both of these variables have two variables so the null Hypothesis is H 0 : There is no association between exclusive territory and success. In this situation. Exclusive territory is the explanatory variable and success is the response variable. We should therefore compare the column percents that give the conditional distribution of success within each exclusive territory category. To compare firms with an exclusive territory, we examine column percents. For the exclusive territory yes group, there are 108 successful firms out of 142. The column proportion for this cell is 108/142=0.761 SuccessYesNo Yes76%54% NO24%46% Total100% Exclusive Territory Under the null hypothesis that success and exclusive territory are independedent P (success and exclusive) =P success X P exclusive The expected count can be found by multiplying the probability by the total # of franchises Exclusive territory SuccessYesNoTotal Yes No Total Step1: Hypothesis H o : Success and exclusive territory are independent. H a : Success and exclusive territory are dependent. Step 2: Conditions To use the chi square test of association/independence, we must check that all expected cell counts are at least 1 and no more than 20% are less than 5. From table D P is between 0.01 an 0.02 P. 756 P. 761 13.19, 13.20