1 / 94

Chapter 14 Inference for Distributions of Categorical Variables: Chi-Square Procedures

Chapter 14 Inference for Distributions of Categorical Variables: Chi-Square Procedures. AP Statistics Hamilton/Mann. Chapter 14 Section 1. Test for Goodness of Fit HW: 14.1, 14.3, 14.6, 14.8. Test for Goodness of Fit.

doane
Download Presentation

Chapter 14 Inference for Distributions of Categorical Variables: Chi-Square Procedures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 14Inference for Distributions of Categorical Variables: Chi-Square Procedures AP Statistics Hamilton/Mann

  2. Chapter 14 Section 1 Test for Goodness of Fit HW: 14.1, 14.3, 14.6, 14.8

  3. Test for Goodness of Fit • Suppose you open up a 1.69-ounce bag of M&M’s Milk Chocolate Candies and discover that out of 56 total M&M’s in the bag, there are only 2 red M&M’s. • Knowing that 13% of all plain M&M’s made by the M&M/Mars Company are red, and that in our sample, the proportion of reds is you feel cheated out of some reds. • You could use the z test described in Chapter 12 to test the hypotheses where p is the proportion of reds.

  4. Test for Goodness of Fit • You could then perform additional tests of significance on each of the other colors. • This, however, would be inefficient. More important, it wouldn’t tell us how likely it is that the six sample proportions differ from the values stated by M&M/Mars Company as much as our sample does. • There is a single test that can be applied to see if the observed sample distribution is significantly different in some way from the hypothesized population distribution. • This test is called the chi-square (χ2) test for goodness of fit.

  5. Auto Accidents and Cell Phones • Are you more likely to have a motor vehicle collision when using a cell phone? A study of 699 drivers who were using a cell phone when they were involved in a collision 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:

  6. Auto Accidents and Cell Phones • We have a total of 699 accidents involving drivers who were using a cell phone at the time of their accident. Let’s explore the relationship between these accidents and the day of the week. Are the accidents equally likely to occur on any day of the week? • We can think of this table of counts as a one-way table with seven cells, each with a count of the number of accidents that occurred on the particular day of the week.

  7. Auto Accidents and Cell Phones • Our question is translated into the following hypotheses: • We can also write it in terms of population proportions.

  8. Goodness of Fit Test • The idea of a goodness of fit test is this: we compare the observed counts for our sample with the counts that would be expected if the null hypothesis were true. • The more the observed counts differ from the expected counts, the more evidence we have to reject H0 and conclude some of the proportions must be different than those we had in the null hypothesis. • In general, the expected count for any categorical variable is obtained by multiplying proportion of the distribution for each category by the sample size.

  9. Auto Accidents and Cell Phones • Before proceeding with a significance test, it’s always a good idea to plot the data. In this case, a bar graph allows you to compare the observed number of accidents by day with the expected numbers of accidents by day. The counts as well as the percents are given in the table below.

  10. Auto Accidents and Cell Phones • Notice the percents did not add to 100% because of rounding error. • Now, we need to calculate the expected counts for each day. Since there are 699 accidents and we are assuming that the probability of an accident is the same for each day, the expected number of accidents is given by • The Bar Graph comparing the expected and observed counts is on the next page.

  11. Auto Accidents and Cell Phones • Anything jump out at you from the bar graph?

  12. Auto Accidents and Cell Phones • 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 H0. The procedure is to calculate the quantity for each day and then add up these terms. The sum is denoted X2 and is called the chi-square statistic. • So let’s figure out what the chi-square statistic is for our example.

  13. Auto Accidents and Cell Phones

  14. Chi-Square Distribution • The larger the difference between the observed and expected values, the larger X2 will be, and the more evidence there will be against H0. • The chi-square family of distribution curves is used to assess the evidence against H0 represented in the value of X2. The specific member of the family is determined by the degrees of freedom. • A χ2 distribution with k degrees of freedom is written χ2(k). • Since we are working not only with counts, but percents, six of the seven percents are free to vary, but the seventh is not since it would de determined by the first six. So there are 6 degrees of freedom.

  15. Chi-Square Distribution • Degrees of freedom is one less than the number of cells in the one-way table (not including the total column). • Table D shows a typical chi-square curve with the right-tail area shaded. • The chi-square test statistic is a point on the horizontal axis, and the area to the right under the curve is the P-value of the test. • This P-value is the probability of observing a value of X2 at least as extreme as the one observed. • The larger the value of the chi-square statistic, the smaller the P-value and the more evidence you have against the null hypothesis H0.

  16. Auto Accidents and Cell Phones • Looking at the Chi-Square Table, a P-value of 0.0005 with 6 degrees of freedom has a value of 24.10. Since our X2 = 208.847 is more extreme than the 24.10 in the table, the probability of observing a result as the extreme as the one we observed, by chance alone, is less than 0.05%. • So, there is sufficient evidence to reject H0 and conclude that these types of accidents are not equally likely to occur on each of the seven days of the week.

  17. Test for Goodness of Fit • The chi-square test applied to the hypothesis that a categorical variable has a specified distribution is called the test for goodness of fit. • The idea is that the test assesses whether the observed counts “fit” the hypothesized distribution. • The details are on the next slide!

  18. Conditions for Goodness of Fit Test • Notice that we don’t want to divide by zero, and since we are working with counts, we require that all expected counts be greater than 1. • In checking conditions, remember that it is the expected counts, not the observed counts, that are important. • Also notice that no more than 20% (1 out of 5) can have expected counts less than 5.

  19. Properties of the Chi-Square Distribution • As the degrees of freedom increase, the density curve becomes less skewed and larger values for X2 become more likely. • Table D gives critical values for chi-square distributions. To get P-values for a chi-square test, you can use Table D, computer software, or your calculator.

  20. Properties of the Chi-Square Distribution • The chi-square density curves have the following properties: • The total area under a chi-square curve is equal to 1. • Each chi-square curve (except when degrees of freedom = 1) begins at 0 on the horizontal axis, increases to a peak, and them approaches the horizontal axis asymptotically from above. • Each chi-square curve is skewed to the right. As the number of degrees of freedom increase, the curve becomes more and more symmetrical and looks more like a Normal curve.

  21. Properties of the Chi-Square Distribution

  22. One Application of the Chi-Square Goodness of Fit Test • This is often used in the field of genetics. • Scientists want to investigate the genetic characteristics of offspring that result from mating parents with known genetic makeups. • Scientists use rules about dominant and recessive genes to predict the ratio of offspring that will fall in each possible genetic category. • Then the researchers mate the parents and classify the resulting offspring. • The chi-square goodness of fit test helps the scientists assess the validity of their hypothesized ratios.

  23. Red-eyed Fruit Flies • Scientists wish to mate two fruit flies having genetic makeup RrCc, indicating that each parent has one dominant gene (R) and one gene (r) for eye color, along with one dominant (C) and one recessive (c) gene for wing type. • R is red-eyed and C is straight-winged. • Each offspring receives one gene for each of the two traits from each parent. • Let’s create the Punnett Square to show the possible genotypes the offspring could end up with.

  24. Red-eyed Fruit Flies • Based on what we see in the Punnett Square: • Probability of red-eyed and straight-winged is • Probability of red-eyed and curly-winged is • Probability of white-eyed and straight-winged is • Probability of white-eyed and curly-winged is • 9 out of 16. • 3 out of 16. • 3 out of 16. • 1 out of 16.

  25. Red-eyed Fruit Flies • To test their hypothesis about the distribution of offspring, the biologists mate the fruit flies. • Of 200 offspring, 99 had red eyes and straight wings, 42 had red eyes and curly wings, 49 had white eyes and straight wings, and 10 had white eyes and curly wings. • Do these results differ significantly from what the biologists would have predicted? • We are going to use the inference toolbox to carry out the significance test.

  26. Red-eyed Fruit Flies • Step 1 – Hypotheses – The biologists are interested in the proportion of offspring that fall into each genetic category for the population of all fruit flies that would result from crossing two parents with genetic makeup RrCc. The hypotheses would be: • Step 2 – Conditions – We must run a chi-square goodness of fit test. We must check expected counts. Since all are greater than 5, we can proceed.

  27. Red-eyed Fruit Flies • Step 3 – Calculations • We have 3 degrees of freedom since there are 4 categories. Our X2 value is between 5.32 and 6.25 which correspond to P-values of 0.15 and 0.10. (On the calculator we get a P-value of 0.1029.)

  28. Red-eyed Fruit Flies • Step 4 – Interpretation • Since the p-value (0.1029) is fairly large, that means that observed differences as large as we saw would happen by chance fairly regularly. Therefore, there is not sufficient evidence to reject the null hypothesis and reject the scientists’ predicted distribution. • We can also do this on the calculator. • Enter observed values in list 1. • Calculate expected values and enter in list 2. • Click Stat and go to Tests and choose D: χ2GOF-Test. • Tell the calculator where the observed and expected counts are, input your degrees of freedom and calculate. Read the results!

  29. Follow-Up Analysis • In the chi-square test for goodness of fit, we test the null hypothesis that a categorical variable has a specified distribution. • If we find significance, we can conclude that our variable has a distribution different from the specified one. In this case, it’s a good idea to determine which categories of the variable provide the greatest differences between observed and expected counts. • To do this, look at the individual terms that are added together to produce the test statistic X2.

  30. Follow-Up Analysis • For the fruit flies example, the third category (white-eyed, straight-winged) contributed the most (3.5267) to the X2 statistic. • For the days of the week that accidents occurred due to cell phone use, Saturday (77.299) and Sunday (63.863) contributed the most to the X2 statistic. • This is known as the largest component of the chi-square statistic. This is the component whose percentage is very different from the hypothesized value.

  31. Chapter 14 Section 2 Inference for Two-Way Tables HW: 14.28, 29, 31, 32

  32. Inference for Two-Way Tables • Two-sample z procedures of Chapter 13 allow us to compare the proportion of successes in two groups (either two populations or two treatments in an experiment). • What if we want to compare more than two groups? • Then we need a new statistical test. • This new test begins by presenting the data as a two-way table. • Two-way tables have more general uses than comparing the proportions of successes in several groups.

  33. Inference for Two-Way Tables • As we saw in Section 2 of Chapter 4, two-way tables can be used to describe relationships between any two categorical variables. • The same test that compares several proportions also tests whether the row and column variables are related in any two-way table. • We will start with the problem of comparing several proportions.

  34. Background Music and Purchasing Wine • Market researchers know that background music can influence the mood and purchasing behavior of customers. One study in a supermarket in Northern Ireland compared three treatments: no music, French accordion music, and Italian string music. Under each condition, the researchers recorded the number of bottles of French, Italian, and other wine purchased. Here is a table with the data

  35. Background Music and Purchasing Wine • The conditional distributions of types of wine sold for each kind of music (this means that the music must total to 100%) are given in the table below. • This compares the distributions (percents) of the types of wines sold based on the music condition. • Just like earlier, now we want to look at bar graphs comparing the different distributions.

  36. Background Music and Purchasing Wine • Do you notice anything?

  37. Background Music and Purchasing Wine • There appears to be an association between music and the type of wine purchased. • When no music is played, other wine is purchased most often and very little Italian wine is purchased. • When French music is played, more French wine is sold and very little Italian. • When Italian music is played, the percent of Italian wine purchased increases dramatically. • What if we instead looked at the conditional distributions of types of music for each kind of wine (this means that the wine type must total to 100%).

  38. Background Music and Purchasing Wine • The conditional distributions of types of music for each kind wine are given below. • This shows that Italian wine is the wine most affected by music type. The other two types of wine have percentages that stay fairly consistent. • Let’s look at these bar graphs.

  39. Background Music and Purchasing Wine • So, what do we notice?

  40. Background Music and Purchasing Wine • It appears that more French wine is sold when French music is playing. • Similarly for Italian wine and Italian music. • It also appears that French music has a dramatic negative impact on sales of Italian wine.

  41. Problem of Multiple Comparisons • The researchers expected the type of music being played would influence sales, so type of music is the explanatory variable and type of wine purchased is the response variable. • In general, the clearest way to describe this type of relationship is to compare the conditional distributions of the response variable for each value of the explanatory variable. This means that the explanatory variables rows or columns must add up to 100%. • In our case, that means that the music columns must add up to 100%.

  42. Problem of Multiple Comparisons • To compare the three population distributions, we might use chi-square goodness of fit procedures several times and test the following hypotheses: • H0: the distribution of wine types for no music is the same as the distribution of wine types for French music • H0: the distribution of wine types for no music is the same as the distribution of wine types for Italian music • H0: the distribution of wine types for French music is the same as the distribution of wine types for Italian music

  43. Problem of Multiple Comparisons • The weakness of doing three tests is that we get three results, one for each test alone. That doesn’t tell us how likely it is that the three sample distributions are as different as these if the corresponding population distributions are the same. • It may be that the sample distributions are significantly different if we look at just two groups, but not significantly different if we look at two other groups. • We can’t safely compare many parameters by doing tests or confidence intervals for two parameters at a time.

  44. Problem of Multiple Comparisons • The problem of how to do many comparisons at once with some overall measure of confidence in all our conclusions is common in statistics. • This is the problem of multiple comparisons. • Statistical methods for dealing with multiple comparison usually have two parts: • An overall test to see if there is good evidence of any differences among the parameters that we want to compare. • A detailed follow-up analysis to decide which of the parameters differ and to estimate how large the differences are.

  45. Problem of Multiple Comparisons • The test we use is one we are now familiar with – the chi-square test – but in this new setting it will be used to compare several population proportions. • The follow-up analysis can be quite elaborate.

  46. Two-Way Tables • The first step in the overall test for comparing several population proportions is to arrange the data in a two-way table that gives the counts for both successes and failures. • A table with r rows and c columns is called an r x c table. • The table shows the relationship between two categorical variables. • For our example, the type of music is the explanatory variable and the type of wine purchased is the response variable.

  47. Stating Hypotheses • We observe a clear relationship between music type and wine sales for the 243 bottles sold during the study. • The chi-square test assesses whether this observed association is statistically significant, that is, too strong to occur often just by chance. • The market researchers changed the background music and took three samples of wine sales in three distinct environments. • Each column in the table represents one of these samples, and each row a wine type.

  48. Stating Hypotheses • This is an example of separate and independent random samples from each of c populations. • The c columns of the two-way table represent the populations. • There is a single categorical response variable, wine type. • The r rows of the table correspond to the values of the response variable. • The r x c table allows us to compare more than two populations, more than two categories of response, or both.

  49. Stating Hypotheses • In this setting, the null hypothesis becomes: H0: The distribution of the response variable is the same in all c populations. • Because the response variable is categorical, its distribution just consists of the proportions of its r possible values or categories. • The null hypothesis says that these population proportions are the same in all c populations.

More Related