Top Banner
Slide 26 - 1 Copyright © 2010 Pearson Education, Inc.
23

Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Mar 27, 2015

Download

Documents

Tyler Callahan
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 1Copyright © 2010 Pearson Education, Inc.

Page 2: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 2Copyright © 2010 Pearson Education, Inc.

Solution: B

Page 3: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Copyright © 2010 Pearson Education, Inc.

Chapter 26Comparing Counts

Page 4: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 4Copyright © 2010 Pearson Education, Inc.

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.

Page 5: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 5Copyright © 2010 Pearson Education, Inc.

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.

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.

Page 6: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 6Copyright © 2010 Pearson Education, Inc.

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:

22

all cells

Obs Exp

Exp

Page 7: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 7Copyright © 2010 Pearson Education, Inc.

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.

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.

Page 8: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 8Copyright © 2010 Pearson Education, Inc.

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.

Page 9: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 9Copyright © 2010 Pearson Education, Inc.

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

2Observed Expected

Expected

Page 10: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 10Copyright © 2010 Pearson Education, Inc.

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.

Page 11: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 11Copyright © 2010 Pearson Education, Inc.

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.

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.

Page 12: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 12Copyright © 2010 Pearson Education, Inc.

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.

Page 13: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 13Copyright © 2010 Pearson Education, Inc.

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

22

all cells

Obs Exp

Exp

Page 14: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 14Copyright © 2010 Pearson Education, Inc.

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:

Obs Expc

Exp

Page 15: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 15Copyright © 2010 Pearson Education, Inc.

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.

Page 16: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 16Copyright © 2010 Pearson Education, Inc.

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.

Page 17: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 17Copyright © 2010 Pearson Education, Inc.

What have we learned?

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.

Page 18: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 18Copyright © 2010 Pearson Education, Inc.

Example: It has been proposed by some researchers that children who are the older ones in their class at school naturally perform better in sports and that these children then get more coaching and encouragement. Could that make a difference in who makes it to the professional level in sports. We have the birthdates of every one of the 16,804 players who ever played in a major league game from 1975 who played through 2006. Let’s test whether the observed distribution of ballplayers’ birth months shows just random fluctuations or whether it represents a real deviation from the national pattern. How can we find the expected counts?

Page 19: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 19Copyright © 2010 Pearson Education, Inc.

Month Ballplayer Count National birth %

1 137 8%

2 121 7%

3 116 8%

4 121 8%

5 126 8%

6 114 8%

7 102 9%

8 165 9%

9 134 9%

10 115 9%

11 105 8%

12 122 9%

Total 1478 100%

Page 20: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 20Copyright © 2010 Pearson Education, Inc.

Example: Are the assumptions and conditions met for performing a goodness-of-fit test?

Example: What are the hypotheses, and what does the test show?

Example: What’s different about the distribution of birth months among major league ball players?

Page 21: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 21Copyright © 2010 Pearson Education, Inc.

Example: Tiny black potato flea beetles can damage potato plants. These pests chew holes in the leaves, causing the plants to die. They can be killed with an insecticide, but canola oil spray has been suggested as a “natural” method of controlling the beetles. We gather 500 beetles and place them in 3 containers. Two hundred in the first container, they are sprayed with canola oil. 200 are in the second container, sprayed with insecticide. 100 in the last container serve as a control group. We wait 6 hours and count the number of surviving beetles in each container.

a. Why do we need the control group?b. What would our null hypothesis be?c. After the experiment is over, we could summarize the results in a

table. Draw the table and calculate the degrees of freedom for our chi-squared test.

d. All together, 125 beetles survived. What’s the expected count in the first cell – survivors among those sprayed with the natural spray?

e. If it turns out that only 40 of the beetles in the first container survived, what’s the calculated component of chi-squared for that cell?

f. If the total calculated value of chi-squared for this table turns out to be around 10, would you expect the P-value of our test to be large or small? Explain.

Page 22: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 22Copyright © 2010 Pearson Education, Inc.

Which of following chi-square tests would you use to calculate each of the following situations? (goodness-of-fit, homogeneity, or independence)

a. A restaurant manger wonders whether customers who dine on Friday nights have the same preferences among the four “chef’s specials” entrees as those who dine on Saturday nights. One weekend he has the wait staff record which entrees were ordered each night. Assuming these customers to be typical of all weekend diners, he’ll compare the distributions of meals chosen Friday and Saturday.

b. Company policy calls for parking spaces to be assigned to everyone at random, but you suspect that may not be so. There are three lots of equal size: lot A, next to the building; lot B, at bit father away, and lot C, on the other side of the highway. You gather data about employees at middle management level and above to see how many were assigned parking in each lot.

c. Is a student’s social life affected by where the student lives? A campus survey asked a random sample of students whether they lived in a dorm, in off-campus housing, or at home and whether they had been out on a date 0, 1-2, 3-4, or 5 or more times in the past two months.

Page 23: Copyright © 2010 Pearson Education, Inc. Slide 26 - 1.

Slide 26 - 23Copyright © 2010 Pearson Education, Inc.

Homework: Pg. 642 1,2,3-9

(day 2) pg. 642 13-29 odd