Copyright © 2009 Pearson Education, Inc. Chapter 26 Comparing Counts.

Slides:



Advertisements
Similar presentations
Copyright © 2010 Pearson Education, Inc. Slide
Advertisements

Chapter 26 Comparing Counts
Chapter 11 Other Chi-Squared Tests
Multinomial Experiments Goodness of Fit Tests We have just seen an example of comparing two proportions. For that analysis, we used the normal distribution.
CHAPTER 23: Two Categorical Variables: The Chi-Square Test
Chapter 11 Inference for Distributions of Categorical Data
Copyright ©2006 Brooks/Cole, a division of Thomson Learning, Inc. More About Categorical Variables Chapter 15.
1-1 Copyright © 2015, 2010, 2007 Pearson Education, Inc. Chapter 25, Slide 1 Chapter 25 Comparing Counts.
Chapter 26: Comparing Counts
Lesson Inference for Two-Way Tables. Vocabulary Statistical Inference – provides methods for drawing conclusions about a population parameter from.
GOODNESS OF FIT TEST & CONTINGENCY TABLE
Copyright © 2012 Pearson Education. All rights reserved Copyright © 2012 Pearson Education. All rights reserved. Chapter 15 Inference for Counts:
 Involves testing a hypothesis.  There is no single parameter to estimate.  Considers all categories to give an overall idea of whether the observed.
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Chapter 26 Comparing Counts.
Chapter 26: Comparing Counts AP Statistics. Comparing Counts In this chapter, we will be performing hypothesis tests on categorical data In previous chapters,
Copyright © 2010 Pearson Education, Inc. Warm Up- Good Morning! If all the values of a data set are the same, all of the following must equal zero except.
Copyright © 2013 Pearson Education, Inc. All rights reserved Chapter 10 Inferring Population Means.
Copyright © 2013, 2010 and 2007 Pearson Education, Inc. Chapter Inference on Categorical Data 12.
CHAPTER 26: COMPARING COUNTS OF CATEGORICAL DATA To test claims and make inferences about counts for categorical variables Objective:
Copyright © 2010, 2007, 2004 Pearson Education, Inc. 1.. Section 11-2 Goodness of Fit.
Multinomial Experiments Goodness of Fit Tests We have just seen an example of comparing two proportions. For that analysis, we used the normal distribution.
Chapter 26 Chi-Square Testing
Chapter 26: Comparing counts of categorical data
Chi-Square Procedures Chi-Square Test for Goodness of Fit, Independence of Variables, and Homogeneity of Proportions.
Other Chi-Square Tests
1-1 Copyright © 2015, 2010, 2007 Pearson Education, Inc. Chapter 25, Slide 1 Chapter 26 Comparing Counts.
Section Copyright © 2014, 2012, 2010 Pearson Education, Inc. Lecture Slides Elementary Statistics Twelfth Edition and the Triola Statistics Series.
Section Copyright © 2014, 2012, 2010 Pearson Education, Inc. Lecture Slides Elementary Statistics Twelfth Edition and the Triola Statistics Series.
Slide 26-1 Copyright © 2004 Pearson Education, Inc.
The Practice of Statistics Third Edition Chapter (13.1) 14.1: Chi-square Test for Goodness of Fit Copyright © 2008 by W. H. Freeman & Company Daniel S.
Other Chi-Square Tests
Copyright © 2010 Pearson Education, Inc. Slide
Comparing Counts.  A test of whether the distribution of counts in one categorical variable matches the distribution predicted by a model is called a.
Chapter 13 Inference for Counts: Chi-Square Tests © 2011 Pearson Education, Inc. 1 Business Statistics: A First Course.
Copyright © Cengage Learning. All rights reserved. Chi-Square and F Distributions 10.
Copyright © 2010 Pearson Education, Inc. Warm Up- Good Morning! If all the values of a data set are the same, all of the following must equal zero except.
Lesson Inference for Two-Way Tables. Knowledge Objectives Explain what is mean by a two-way table. Define the chi-square (χ 2 ) statistic. Identify.
11.2 Tests Using Contingency Tables When data can be tabulated in table form in terms of frequencies, several types of hypotheses can be tested by using.
Copyright © 2013, 2009, and 2007, Pearson Education, Inc. Chapter 11 Analyzing the Association Between Categorical Variables Section 11.2 Testing Categorical.
ContentFurther guidance  Hypothesis testing involves making a conjecture (assumption) about some facet of our world, collecting data from a sample,
Comparing Counts Chapter 26. Goodness-of-Fit A test of whether the distribution of counts in one categorical variable matches the distribution predicted.
+ Section 11.1 Chi-Square Goodness-of-Fit Tests. + Introduction In the previous chapter, we discussed inference procedures for comparing the proportion.
1 Copyright © 2014, 2012, 2009 Pearson Education, Inc. Chapter 22 Comparing Counts.
Statistics 26 Comparing Counts. Goodness-of-Fit A test of whether the distribution of counts in one categorical variable matches the distribution predicted.
Chapter 11: Categorical Data n Chi-square goodness of fit test allows us to examine a single distribution of a categorical variable in a population. n.
Comparing Observed Distributions A test comparing the distribution of counts for two or more groups on the same categorical variable is called a chi-square.
Chapter 26 Comparing Counts. Objectives Chi-Square Model Chi-Square Statistic Knowing when and how to use the Chi- Square Tests; Goodness of Fit Test.
Goodness-of-Fit A test of whether the distribution of counts in one categorical variable matches the distribution predicted by a model is called a goodness-of-fit.
Comparing Counts Chi Square Tests Independence.
Other Chi-Square Tests
CHAPTER 26 Comparing Counts.
Presentation 12 Chi-Square test.
Chapter 12 Tests with Qualitative Data
Chapter 25 Comparing Counts.
1) A bicycle safety organization claims that fatal bicycle accidents are uniformly distributed throughout the week. The table shows the day of the week.
Chapter 11 Goodness-of-Fit and Contingency Tables
Elementary Statistics
Sun. Mon. Tues. Wed. Thurs. Fri. Sat.
Chapter 11: Inference for Distributions of Categorical Data
15.1 Goodness-of-Fit Tests
Inference on Categorical Data
Lesson 11 - R Chapter 11 Review:
Paired Samples and Blocks
Analyzing the Association Between Categorical Variables
WELCOME BACK! days From: Tuesday, January 3, 2017
Chapter 26 Comparing Counts.
Section 11-1 Review and Preview
Chapter 26 Comparing Counts Copyright © 2009 Pearson Education, Inc.
Chapter 26 Comparing Counts.
Inference for Distributions of Categorical Data
Presentation transcript:

Copyright © 2009 Pearson Education, Inc. Chapter 26 Comparing Counts

Copyright © 2009 Pearson Education, Inc. Slide 1- 3 Objectives: The student will be able to: Perform chi-square tests for goodness-of-fit, homogeneity, and independence, to include: writing appropriate hypotheses, checking the necessary assumptions, drawing an appropriate diagram, computing the P-value, making a decision, and interpreting the results in the context of the problem.

Copyright © 2009 Pearson Education, Inc. Slide 1- 4 Goodness-of-Fit A test of whether the distribution of counts in one categorical variable matches the distribution predicted by a model is called a goodness-of-fit test. As usual, there are assumptions and conditions to consider…

Copyright © 2009 Pearson Education, Inc. Slide 1- 5 Assumptions and Conditions Counted Data Condition: Check that the data are counts for the categories of a categorical variable. Independence Assumption: The counts in the cells should be independent of each other. Randomization Condition: The individuals who have been counted and whose counts are available for analysis should be a random sample from some population.

Copyright © 2009 Pearson Education, Inc. Slide 1- 6 Assumptions and Conditions (cont.) Sample Size Assumption: We must have enough data for the methods to work. Expected Cell Frequency Condition: We should expect to see at least 5 individuals in each cell. This is similar to the condition that np and nq be at least 10 when we tested proportions.

Copyright © 2009 Pearson Education, Inc. Hypotheses for a goodness of fit test H 0 : The distribution of counts occurs in a manner consistent with our model. For example, if our model is a uniform distribution we might say p 1 =p 2 =p 3 =p 4 H A : the distribution of counts occurs in a manner which is inconsistent with our model. Note: the distribution of counts can vary from our model in many different ways! Slide 1- 7

Copyright © 2009 Pearson Education, Inc. Slide 1- 8 Calculations Since we want to examine how well the observed data reflect what would be expected, it is natural to look at the differences between the observed and expected counts (Obs – Exp). These differences are actually residuals, so we know that adding all of the differences will result in a sum of 0. That’s not very helpful.

Copyright © 2009 Pearson Education, Inc. Slide 1- 9 Calculations (cont.) We’ll handle the residuals as we did in regression, by squaring them. To get an idea of the relative sizes of the differences, we will divide these squared quantities by the expected values.

Copyright © 2009 Pearson Education, Inc. Slide Calculations (cont.) The test statistic, called the chi-square (or chi- squared) statistic, is found by adding up the sum of the squares of the deviations between the observed and expected counts divided by the expected counts:

Copyright © 2009 Pearson Education, Inc. Slide Calculations (cont.) The chi-square models are actually a family of distributions indexed by degrees of freedom (much like the t-distribution). The number of degrees of freedom for a goodness-of-fit test is n – 1, where n is the number of categories.

Copyright © 2009 Pearson Education, Inc. Slide Chi-Square P-Values The chi-square statistic is used only for testing hypotheses, not for constructing confidence intervals. If the observed counts don’t match the expected, the statistic will be large—it can’t be “too small.” So the chi-square test is always one-sided. If the calculated value is large enough, we’ll reject the null hypothesis.

Copyright © 2009 Pearson Education, Inc. Slide The mechanics may work like a one-sided test, but the interpretation of a chi-square test is in some ways many-sided. There are many ways the null hypothesis could be wrong. There’s no direction to the rejection of the null model—all we know is that it doesn’t fit. Chi-Square P-Values (cont.)

Copyright © 2009 Pearson Education, Inc. Slide The Chi-Square Calculation 1.Find the expected values: Every model gives a hypothesized proportion for each cell. The expected value is the product of the total number of observations times this proportion. 2.Compute the residuals: Once you have expected values for each cell, find the residuals, Observed – Expected. 3.Square the residuals.

Copyright © 2009 Pearson Education, Inc. Slide The Chi-Square Calculation (cont.) 4.Compute the components. Now find the components for each cell. 5.Find the sum of the components (that’s the chi- square statistic).

Copyright © 2009 Pearson Education, Inc. Slide The Chi-Square Calculation (cont.) 6.Find the degrees of freedom. It’s equal to the number of cells minus one. 7.Test the hypothesis.  Use your chi-square statistic to find the P-value. (Remember, you’ll always have a one-sided test.)  Large chi-square values mean lots of deviation from the hypothesized model, so they give small P-values.

Copyright © 2009 Pearson Education, Inc. Using our calculator -- only for TI 84+ χ 2 Goodness-of-Fit Test for the TI-84 Plus Calculator It is relatively easier to conduct a χ2 goodness-of-fit test if you happen to have a TI-84 Plus calculator. Enter the observed frequencies in L1 and the expected frequencies in L2 Go to Stat -> Tests -> D:X 2 GOF-Test Your calculator will prompt you for the list with the observed frequencies ( L1 for this example) and the list with the expected frequencies (L2 for this example), and the number of degrees of freedom. You can find the degrees of freedom by subtracting 1 from the number of categories (k – 1). Then press Calculate Slide 1- 17

Copyright © 2009 Pearson Education, Inc. TI-83+ for x 2 Goodness of Fit test Enter the observed frequencies in L 1 and the expected frequencies in L 2. Highlight L 3 and type (L 1 - L 2 ) 2 / L 2 enter The computed values should appear in L 3 We now need to sum the values in L 3. We do this by going to List (2 nd Stat) -> MATH -> 5: sum Sum(L 3 ) this gives us our x 2 statistic. To find the p-value we need to go to DISTR (2 nd Vars) -> 7: x 2 cdf(Ans, 1E99, df) Where Ans is the x 2 statistic just calculated 1E99 is a very large number, and df is (# categories – 1) Slide 1- 18

Copyright © 2009 Pearson Education, Inc. A die is filled with a lead weight and then rolled 200 times with the following results: 1: 27 2: 31 3: 42 4: 40 5: 28 6: 32 Use an alpha of 0.05 to test the claim that the outcomes are not equally likely (Triola 2008). H0: The die rolls are evenly distributed over 1-6. HA: The die rolls are not evenly distributed over 1-6 (i.e. the die is not “fair”). Test Statistic (X2) = 5.86 P-Value = 0.32 Conclusion: Since the P-value is greater than alpha, we cannot reject the null hypothesis. Therefore, there is not enough statistical evidence to support the claim that the die is not fair. Slide 1- 19

Copyright © 2009 Pearson Education, Inc. 37. The following data lists automobile fatalities by day of week: Sun: 132 Mon: 98 Tue: 95 Wed: 98 Thu: 105 Fri: 133 Sat: 158 Use an alpha of 0.05 to test the claim that the outcomes are not uniformly spread across the days of the week (Triola 2008). H0: Automobile fatalities are evenly distributed over all seven days of the week. HA: Automobile fatalities are not evenly distributed over all seven days of the week. Test Statistic (X2) = P-Value = Small # Conclusion: Since the P-value is less than alpha, we can reject the null hypothesis. Therefore, the statistical evidence suggests that driving fatalities are not evenly spread throughout the days of the week. Slide 1- 20

Copyright © 2009 Pearson Education, Inc. 38. The following data lists the birth months of Oscar-winning actors: Jan: 9 Feb: 5 Mar: 7 Apr: 14 May: 8 Jun: 1 Jul:7 Aug: 6 Sep: 4 Oct: 5 Nov: 1 Dec: 9 Use an alpha of 0.05 to test the claim that the outcomes are not uniformly spread across the months (Triola 2008). H0: Actor birth months are uniformly spread out over all 12 months. HA: Actor birth months are not uniformly spread out over all 12 months. Test Statistic (X2) = P-Value = 0.02 Conclusion: Since the P-value is less than alpha, we can reject the null hypothesis. Therefore, the statistical evidence suggests that actor birth months are NOT evenly spread out throughout the year. Slide 1- 21

Copyright © 2009 Pearson Education, Inc. 39. You are planning to open an old time soda fountain and your partner claims that the public will not prefer any flavor over another. The flavors you serve are cherry, strawberry, orange, lime and grape. After several customers, you stop and take a look at how sales are going and here are the results. The following numbers of people ordered the flavor shown. Cherry 35, Strawberry 32, Orange 29, Lime 26 and Grape 25. Test to see if there was a preference at the 0.05 significance level. H0: The customers have no preference for any flavor. HA: The customers have flavor preferences. Test Statistic (X2) = 2.35 P-Value = 0.67 Conclusion: Since the P-value is larger than alpha, we cannot reject the null hypothesis. Therefore, there is no statistical evidence that customers prefer some flavors more than others. Slide 1- 22

Copyright © 2009 Pearson Education, Inc. Slide But I Believe the Model… Goodness-of-fit tests are likely to be performed by people who have a theory of what the proportions should be, and who believe their theory to be true. Unfortunately, the only null hypothesis available for a goodness-of-fit test is that the theory is true. As we know, the hypothesis testing procedure allows us only to reject or fail to reject the null.

Copyright © 2009 Pearson Education, Inc. Slide But I Believe the Model… (cont.) We can never confirm that a theory is in fact true. At best, we can point out only that the data are consistent with the proposed theory. Remember, it’s that idea of “not guilty” versus “innocent.”

Copyright © 2009 Pearson Education, Inc. Slide Comparing Observed Distributions A test comparing the distribution of counts for two or more groups on the same categorical variable is called a chi-square test of homogeneity. A test of homogeneity is actually the generalization of the two-proportion z-test.

Copyright © 2009 Pearson Education, Inc. Slide Comparing Observed Distributions (cont.) The statistic that we calculate for this test is identical to the chi-square statistic for goodness- of-fit. In this test, however, we ask whether choices have changed (i.e., there is no model). The expected counts are found directly from the data and we have different degrees of freedom.

Copyright © 2009 Pearson Education, Inc. Slide Assumptions and Conditions The assumptions and conditions are the same as for the chi-square goodness-of-fit test: Counted Data Condition: The data must be counts. Randomization Condition and 10% Condition: As long as we don’t want to generalize, we don’t have to check these condition. Expected Cell Frequency Condition: The expected count in each cell must be at least 5.

Copyright © 2009 Pearson Education, Inc. Slide Calculations To find the expected counts, we multiply the row total by the column total and divide by the grand total. We calculated the chi-square statistic as we did in the goodness-of-fit test: In this situation we have (R – 1)(C – 1) degrees of freedom, where R is the number of rows and C is the number of columns. We’ll need the degrees of freedom to find a P-value for the chi-square statistic.

Copyright © 2009 Pearson Education, Inc. Slide Independence Contingency tables categorize counts on two (or more) variables so that we can see whether the distribution of counts on one variable is contingent on the other. A test of whether the two categorical variables are independent examines the distribution of counts for one group of individuals classified according to both variables in a contingency table. A chi-square test of independence uses the same calculation as a test of homogeneity.

Copyright © 2009 Pearson Education, Inc. Slide Assumptions and Conditions We still need counts and enough data so that the expected values are at least 5 in each cell. If we’re interested in the independence of variables, we usually want to generalize from the data to some population. In that case, we’ll need to check that the data are a representative random sample from that population.

Copyright © 2009 Pearson Education, Inc. Hypotheses for a x 2 test of independence H 0 : the variables are independent i.e. the distribution of counts is the same for each group. H A : the variables are not independent OR can say: (they are dependent, i.e. associated) i.e. the distribution of counts are different among the groups. Slide 1- 31

Copyright © 2009 Pearson Education, Inc. X 2 test for Independence using the TI A sociologist wishes to see whether the number of years of college a person has completed is related to his or her place of residence. A sample of 84 is selected and classified as shown. (The best way to arrange data for a study involving independence is to create a contingency table made up of "i" rows and "j" columns.) LocationNo CollegeBachelorsMasters PhD Urban Suburban Rural67127 At  =0.05, can the sociologist conclude that the years of college education are independent of the residence location? We need to get this contingency table into the TI using the Matrx function. Matrx…Edit…enter to get into the matrix [A]. A matrix is called by its rows first and then its columns. So this is a 3 x 4 matrix. Enter these numbers accordingly. Next fill in the matrix as it appears above. Remember to hit enter after each data entry. Then 2 nd Quit. Stat -> Test -> #C x 2 -test. We placed the observed data in [A] and the TI will place the expected values in [B] or anywhere you stipulate. Then ask the TI to calculate. You get a computed x 2 of and a p-value of,398. Thus we cannot reject the null hypothesis. This suggests independence. Therefore, place of residence and education level are independent of each other Slide 1- 32

Copyright © 2009 Pearson Education, Inc. Here is a table showing who survived the sinking of the Titanic based on whether they were crew members or passengers booked in first, second or third-class staterooms: CrewFirstSecond ThirdTotal Alive Dead Total Determine if surviving was independent of cabin status (use alpha=0.01). H0: Cabin class and survivorship are independent. HA: Cabin class and survivorship are dependent. Test Statistic (X2) = P-Value = Tiny, tiny # Conclusion: Since the P-value is smaller than alpha, we reject the null hypothesis. Therefore, we can conclude that there is an association (dependence) between cabin class and survivorship. Slide 1- 33

Copyright © 2009 Pearson Education, Inc. 34. Use the following data to do a test of independence to see if left-handedness is independent of gender (use alpha=0.05): Left-HandedRight-Handed Male1783 Female H0: “Handedness” and gender are independent. HA: Handedness and gender are dependent. Test Statistic (X2) = 5.52 P-Value = Conclusion: Since the P-value is smaller than alpha, we reject the null hypothesis. Therefore, we can conclude that there is an association (dependence) between handedness and gender. Slide 1- 34

Copyright © 2009 Pearson Education, Inc. 35. Use the following data to do a test of independence to see if height is independent of gender (use alpha=0.05) ShortTall Male325 Female172 H0: Height and gender are independent. HA: Height and gender are not independent. Test Statistic (X2) = P-Value = Small # Conclusion: Since the P-value is smaller than alpha, we reject the null hypothesis. Therefore, we can conclude that there is an association (dependence) between height and gender. Slide 1- 35

Copyright © 2009 Pearson Education, Inc. Slide Chi-Square and Causation Chi-square tests are common, and tests for independence are especially widespread. We need to remember that a small P-value is not proof of causation. Since the chi-square test for independence treats the two variables symmetrically, we cannot differentiate the direction of any possible causation even if it existed. And, there’s never any way to eliminate the possibility that a lurking variable is responsible for the lack of independence.

Copyright © 2009 Pearson Education, Inc. Slide Chi-Square and Causation (cont.) In some ways, a failure of independence between two categorical variables is less impressive than a strong, consistent, linear association between quantitative variables. Two categorical variables can fail the test of independence in many ways. Examining the standardized residuals can help you think about the underlying patterns.

Copyright © 2009 Pearson Education, Inc. Slide What Can Go Wrong? Don’t use chi-square methods unless you have counts. Just because numbers are in a two-way table doesn’t make them suitable for chi-square analysis. Beware large samples. With a sufficiently large sample size, a chi-square test can always reject the null hypothesis. Don’t say that one variable “depends” on the other just because they’re not independent. Association is not causation.

Copyright © 2009 Pearson Education, Inc. Slide What have we learned? We’ve learned how to test hypotheses about categorical variables. All three methods we examined look at counts of data in categories and rely on chi-square models. Goodness-of-fit tests compare the observed distribution of a single categorical variable to an expected distribution based on theory or model. Tests of homogeneity compare the distribution of several groups for the same categorical variable. Tests of independence examine counts from a single group for evidence of an association between two categorical variables.

Copyright © 2009 Pearson Education, Inc. Slide What have we learned? (cont.) Mechanically, these tests are almost identical. While the tests appear to be one-sided, conceptually they are many-sided, because there are many ways that the data can deviate significantly from what we hypothesize. When we reject the null hypothesis, we know to examine standardized residuals to better understand the patterns in the data.