Statistics 26 Comparing Counts. Goodness-of-Fit A test of whether the distribution of counts in one categorical variable matches the distribution predicted.

Slides:



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

Chapter 26 Comparing Counts
The Analysis of Categorical Data and Goodness of Fit Tests
CHAPTER 23: Two Categorical Variables: The Chi-Square Test
Chapter 11 Inference for Distributions of Categorical Data
1 Chi-Squared Distributions Inference for Categorical Data and Multiple Groups.
1-1 Copyright © 2015, 2010, 2007 Pearson Education, Inc. Chapter 25, Slide 1 Chapter 25 Comparing Counts.
Chapter 26: Comparing Counts
CHAPTER 11 Inference for Distributions of Categorical Data
Chapter 26 Part 1 COMPARING COUNTS. Is an observed distribution consistent with what we expect? Are observed differences among several distributions large.
Chapter 26: Comparing Counts. To analyze categorical data, we construct two-way tables and examine the counts of percents of the explanatory and response.
Chapter 13: Inference for Tables – Chi-Square Procedures
Analysis of Count Data Chapter 26
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.
AP Statistics Chapter 26 Notes
CHAPTER 26: COMPARING COUNTS OF CATEGORICAL DATA To test claims and make inferences about counts for categorical variables Objective:
Chapter 11: Inference for Distributions of Categorical Data.
Lecture 9 Chapter 22. Tests for two-way tables. Objectives The chi-square test for two-way tables (Award: NHST Test for Independence)  Two-way tables.
Chapter 26 Chi-Square Testing
Chapter 26: Comparing counts of categorical data
The Practice of Statistics, 5th Edition Starnes, Tabor, Yates, Moore Bedford Freeman Worth Publishers CHAPTER 11 Inference for Distributions of Categorical.
Chapter 11: Inference for Distributions of Categorical Data Section 11.1 Chi-Square Goodness-of-Fit Tests.
Chi-Square Procedures Chi-Square Test for Goodness of Fit, Independence of Variables, and Homogeneity of Proportions.
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.
Slide 26-1 Copyright © 2004 Pearson Education, Inc.
+ Chi Square Test Homogeneity or Independence( Association)
Chapter 11 Chi- Square Test for Homogeneity Target Goal: I can use a chi-square test to compare 3 or more proportions. I can use a chi-square test for.
Warm up On slide.
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.
1 Chapter 10. Section 10.1 and 10.2 Triola, Elementary Statistics, Eighth Edition. Copyright Addison Wesley Longman M ARIO F. T RIOLA E IGHTH E DITION.
AGENDA:. AP STAT Ch. 14.: X 2 Tests Goodness of Fit Homogeniety Independence EQ: What are expected values and how are they used to calculate Chi-Square?
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.
Section 12.2: Tests for Homogeneity and Independence in a Two-Way Table.
Copyright © 2013, 2009, and 2007, Pearson Education, Inc. Chapter 11 Analyzing the Association Between Categorical Variables Section 11.2 Testing Categorical.
Chapter 12 The Analysis of Categorical Data and Goodness of Fit Tests.
Comparing Counts Chapter 26. Goodness-of-Fit A test of whether the distribution of counts in one categorical variable matches the distribution predicted.
+ Unit 6: Comparing Two Populations or Groups Section 10.2 Comparing Two Means.
+ Section 11.1 Chi-Square Goodness-of-Fit Tests. + Introduction In the previous chapter, we discussed inference procedures for comparing the proportion.
Chi-Squared Test of Homogeneity Are different populations the same across some characteristic?
11.1 Chi-Square Tests for Goodness of Fit Objectives SWBAT: STATE appropriate hypotheses and COMPUTE expected counts for a chi- square test for goodness.
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.
Statistics 22 Comparing Two Proportions. Comparisons between two percentages are much more common than questions about isolated percentages. And they.
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.
Goodness-of-Fit and Contingency Tables Chapter 11.
AP Stats Check In Where we’ve been… Chapter 7…Chapter 8… Where we are going… Significance Tests!! –Ch 9 Tests about a population proportion –Ch 9Tests.
 Check the Random, Large Sample Size and Independent conditions before performing a chi-square test  Use a chi-square test for homogeneity to determine.
Chi Square Test of Homogeneity. Are the different types of M&M’s distributed the same across the different colors? PlainPeanutPeanut Butter Crispy Brown7447.
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.
Copyright © 2009 Pearson Education, Inc. Chapter 26 Comparing Counts.
Check your understanding: p. 684
Warm up On slide.
Comparing Counts Chi Square Tests Independence.
CHAPTER 26 Comparing Counts.
Chapter 25 Comparing Counts.
15.1 Goodness-of-Fit Tests
Inference for Relationships
Paired Samples and Blocks
Analyzing the Association Between Categorical Variables
Chapter 26 Comparing Counts.
Chapter 26 Comparing Counts Copyright © 2009 Pearson Education, Inc.
Chapter 26 Comparing Counts.
Inference for Distributions of Categorical Data
Presentation transcript:

Statistics 26 Comparing Counts

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…

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.

Assumptions and Conditions 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.

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.

Calculations 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 each squared difference by the expected count fro that cell.

Calculations 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:

Calculations 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.

One-Sided or Two-Sided? 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 statistic value is large enough, we’ll reject the null hypothesis.

One-Sided or Two-Sided? 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.

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.

The Chi-Square Calculation 4.Compute the components. Now find the components for each cell. 5.Find the sum of the components (that’s the chi-square statistic).

The Chi-Square Calculation 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. Reject the null with a high P-value

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.

Example Calculate how many of each color you should have found in your bag (based on the total number of candies) Complete a goodness-of-fit test. M&M'S MILK CHOCOLATE: 24% cyan blue, 20% orange, 16% green, 14% bright yellow, 13% red, 13% brown. Each large production batch is blended to those ratios and mixed thoroughly. However, since the individual packages are filled by weight on high-speed equipment, and not by count, it is possible to have an unusual color distribution.

Example Complete a goodness-of-fit test. M&M'S MILK CHOCOLATE: 24% cyan blue, 20% orange, 16% green, 14% bright yellow, 13% red, 13% brown.

But I Believe the Model… 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.”

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.

Comparing Observed Distributions 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 are the same among different groups (i.e., there is no model). The expected counts are found directly from the data and we have different degrees of freedom.

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 conditions. –Expected Cell Frequency Condition: The expected count in each cell must be at least 5.

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.

Examining the Residuals When we reject the null hypothesis, it’s always a good idea to examine residuals. For chi-square tests, we want to work with standardized residuals, since we want to compare residuals for cells that may have very different counts. To standardize a cell’s residual, we just divide by the square root of its expected value:

Examining the Residuals These standardized residuals are just the square roots of the components we calculated for each cell, with the + or the – sign indicating whether we observed more cases than we expected, or fewer. The standardized residuals give us a chance to think about the underlying patterns and to consider the ways in which the distribution might not match what we hypothesized to be true.

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. Independence

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.

Example Medical researchers enlisted 90 subjects for an experiment comparing treatments for depression. The subjects were randomly divided into three groups and given pills to take for a period of three months. Unknown to them, one group received a placebo, the second group the “natural” remedy St. John’s wort, and the third group the prescription drug Posrex. After six months, psychologists and physicians (who did not know which treatment each person had received) evaluated the subjects to see if their depression had returned.

Example Medical researchers enlisted 90 subjects for an experiment comparing treatments for depression. The subjects were randomly divided into three groups and given pills to take for a period of three months. Unknown to them, one group received a placebo, the second group the “natural” remedy St. John’s wort, and the third group the prescription drug Posrex. After six months, psychologists and physicians (who did not know which treatment each person had received) evaluated the subjects to see if their depression had returned.

Example Add row and column totals to the table, Those 60 subjects would be expected to divide under the null hypothesis. We can look at this three ways. Since 30/90 = 1/3 of all subjects got the placebo, 1/3 of the 60 with recurrent depression should have been in the placebo group. Or, since 60/90 = 2/3 of the subjects suffered returning depression, we’d expect that to be true of 2/3 of the 30 who got the placebo. Or, there’s always the mindless explanation: row total column total/grand total = (60× 30)/90 = 20.

Example Add row and column totals to the table, Those 60 subjects would be expected to divide under the null hypothesis. We can look at this three ways. Since 30/90 = 1/3 of all subjects got the placebo, 1/3 of the 60 with recurrent depression should have been in the placebo group. Or, since 60/90 = 2/3 of the subjects suffered returning depression, we’d expect that to be true of 2/3 of the 30 who got the placebo. Or, there’s always the mindless explanation: row total column total/grand total = (60× 30)/90 = 20.

Example Here we have (2 – 1)(3 – 1) = 2 degrees of freedom.

Example

Examine the Residuals Each cell of a contingency table contributes a term to the chi-square sum. It helps to examine the standardized residuals, just like we did for tests of homogeneity.

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.

Chi-Square and Causation 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.

Example

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.

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.

What have we learned? 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.

Homework Pages 628 – 633 1, 4, 6, 10, 11, 16, 20, 22, 24, 26, 30