Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 26 Comparing Counts.

Similar presentations


Presentation on theme: "CHAPTER 26 Comparing Counts."— Presentation transcript:

1 CHAPTER 26 Comparing Counts

2 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. Is one distribution comparable to another or does one distribution fit another? As usual, there are assumptions and conditions to consider…

3 Assumptions and Conditions
Counted Data Condition: Check that the data are counts for the categories of a categorical variable. Independence Assumption: Randomization Condition: The individuals who have been counted 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.

4 Calculations Since we want to examine how well the observed data reflect what would be expected, we look at the differences between the observed and expected counts (Obs – Exp). These differences are residuals, so we know that adding all of the differences will result in a sum of 0. 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.

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

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

7 One-Sided or Two-Sided?
The chi-square statistic is used only for testing hypotheses. 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.

8 The Chi-Square Calculation
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. Compute the residuals: Once you have expected values for each cell, find the residuals, Observed – Expected. Square the residuals.

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

10 The Chi-Square Calculation (cont.)
Find the degrees of freedom. It’s equal to the number of cells minus one. 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.

11 Example Trix cereal comes in five fruit flavors. A student sorted
an entire box of the cereal and found the following distribution of flavors for the pieces of cereal in the box: Test the null hypothesis that the flavors are uniformly distributed versus the alternative that they are not. Flavor Grape Lemon Lime Orange Strawberry Freq 530 470 420 610 585

12 1. State the hypotheses. 2. Model

13 1. State the hypotheses. 2. Model Chi-squared goodness of fit Counted data Randomization – assume random box of cereal Sample Size – all expected counts are 5 or more

14 3. Mechanics

15 3. Mechanics Chi-squared = Flavor Grape Lemon Lime Orange Strawberry EC 523

16 4. Conclusion Since our p-value of 0 is less than .05, we reject the null hypothesis that states the flavors are uniformly distributed. We have sufficient evidence to prove that the flavors are not uniformly distributed.

17 M&M Activity Due Next Class
ASSIGNMENT A#4/3 p. 628 #3, 5, 6, 7 M&M Activity Due Next Class

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

19 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: As long as we don’t want to generalize to the larger population, we don’t have to check this condition. Expected Cell Frequency Condition: The expected count in each cell must be at least 5.

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

21 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. One group received a placebo, the second group St. John’s wort, and the third group the prescription drug Posrex. After six months, psychologists and physicians evaluated the subjects to see if their depression had returned.

22 Perform a chi-squared test of homogeneity on the above data.
Diagnosis Placebo StJ W Posrex Depression returned 24 22 14 No Sign of Depression 6 8 16 Perform a chi-squared test of homogeneity on the above data.

23 1. State the hypotheses. 2. Model

24 1. State the hypotheses. 2. Model Chi-squared test for homogeneity Counted data Randomization – subjects were randomly assigned to groups Expected Cell Frequency – All expected counts are 5 or more?

25 3. Mechanics

26 3. Mechanics Diagnosis Placebo StJ W Posrex Depression returned 20 No sign of depression 10

27 4. Conclusion Since our p-value of is less than .05, we reject the null hypothesis that states the recurrence rates for all three treatments is the same. We have sufficient evidence to prove that the recurrence rates are different for the three treatments.

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

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

30 Example A study of the career plans of young women
and men sent questionnaires to all 724 members of the senior class in the College of Business Administration at the University of Illinois. One question asked which major within the business program the student had chosen. Is there a relationship between the gender of the student and their choice of major?

31 Female Male Accounting 68 56 Administration 91 40 Economics 5 8 Finance 61 59

32 1. State the hypotheses. 2. Model

33 1. State the hypotheses. 2. Model Chi-squared test for independence Counted data Random sample – sent to all students at one University, not fully random Expected Counts – all expected counts 5 or more?

34 3. Mechanics

35 3. Mechanics Female Male Accounting 71.907 52.093 Administration 75.966 55.034 Economics 7.5387 5.4613 Finance 69.588 50.412

36 4. Conclusion Since our p-value of is less than 0.05, we reject the null hypothesis that states there is no relationship between gender and the major that was chosen. We have sufficient evidence to prove that there is a relationship between gender and major.

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

38 Investigative Task Due April 15/16
ASSIGNMENT A#4/4 p. 629 #11, 12, 14, 16, 20 Investigative Task Due April 15/16


Download ppt "CHAPTER 26 Comparing Counts."

Similar presentations


Ads by Google