Presentation is loading. Please wait.

Presentation is loading. Please wait.

STT 200 Statistical Methods

Similar presentations


Presentation on theme: "STT 200 Statistical Methods"— Presentation transcript:

1 STT 200 Statistical Methods
Chapter 3 Inference for Categorical Data Testing For Goodness of Fit Using Chi – square Testing For Independence In Two – Way Tables

2 3.3 Testing For Goodness of Fit Using Chi-square
So far in Chapter 3, we’ve looked at inferential procedures for binomial characteristics that can be summarized with a proportion or with a difference between two proportions. We now explore methods for assessing categorical data with more than two outcomes.

3 Major Steps In The Goodness Of Fit Test Using The Chi-square Procedure
The chi-square statistic can be used to test whether the observed counts in a frequency distribution or contingency table match the counts we would expect according to some model. A test of whether the distribution of counts in one categorical variable matches the distribution predicted by a model is a model called a test of goodness – of – fit. In a chi-square goodness – of – fit test, the expected counts come from the predicting model. The test finds a P – value from a chi-square model with k – 1 degrees of freedom, where n is the number of categories in the categorical variable.

4 Assumptions and Conditions
Counted Data Condition The values in each cell are counts. Doesn’t work with percents, proportions, or measurements. Independence Assumption The counts in each cell must be independent of each other. For random samples, we can generalize to the entire population.

5 Assumptions and Conditions Continued
Sample Size Assumption Expected counts for each cell  5. This is called the Expected Cell Frequency Condition. If the assumptions and conditions are met, we can perform a Chi-Square Test for Goodness-of-Fit.

6 Null and Alternative Hypotheses
Null Hypothesis: The distribution of counts are the same. The observed differences are due to chance. Alternative Hypothesis: The distribution of counts are not the same. The observed differences are not due to chance.

7 Chi-Square Calculations
Interested in difference between observed and expected: residuals. Make positive by squaring them all. Get relative sizes of the residuals by dividing them by the expected counts. This is a Chi-Square Model with df = k – 1. k is the number of categories, not the sample size.

8 A regional transit authority is concerned about the number of riders on one of its bus routes. In setting up the route, the assumption was that the number of riders is the same on every day from Monday through Friday. The transit authority is now concerned this assumption might not be safe to make and records the number of riders on the route for a randomly selected set of weekdays. Monday Tuesday Wednesday Thursday Friday Total 132 164 223 171 160 850

9 Bus Ridership

10 Bus Ridership We know that sample data varies, but it is unclear if this data provides convincing evidence that the ridership if not the same on every weekday. Because the sample is random, we would expect to see small differences due to chance. We need to test whether the differences are significant.

11 Bus Ridership

12 Bus Ridership How many riders would we expect to see on each day, if the transit authority’s assumption (the null hypothesis) was true? Weekday Observed riders Expected riders Monday 132  170 Tuesday 163 Wednesday 223 Thursday 171 Friday 160

13 In previous hypothesis tests, we constructed a test statistic using the following form:
This construction was based on (1) identifying the difference between an observed sample statistic and what the null hypothesis would expect us to observe, and (2) standardizing that difference using the standard error of the sample statistic.

14 When we were comparing one proportion to a claimed parameter or evaluating the difference in two proportions, we used a z – statistic. Now that we are comparing more than two proportions, we need to use a different statistic with a different distribution. This distribution is called the Chi – square distribution.

15

16 These facts will serve as a useful frame of reference for making hypothesis test decisions.

17

18

19 In previous hypothesis tests, we constructed a test statistic using the following form: What would this test statistic be for Mondays? Note: The null standard error in this situation is simply the square root of the expected value under the null hypothesis.

20 What would this test statistic be for the other days?

21 Summing all these test statistics gives a value that summarizes how far the actual counts are from what was expected. As it turns out, it is more common to add the squared values. Summing the squared test statistics has two consequences: 1. All standardized differences will be positive. 2. Unusual differences will become much larger.

22

23 Degrees of Freedom

24 As with other hypothesis tests, certain conditions must apply for the chi-square goodness of fit test to be valid. Condition #1: Each case that contributes a count to the table must be ____independent______of all the other cases in the table. Condition #2: The ___expected____ count for each level of the categorical variable must be at least ____5_____. Condition #3: There must be at least _____3______ levels of the categorical variable, corresponding to a chi- square distribution with at least _____2_____ degrees of freedom

25 Bus Ridership Weekday Observed riders Expected riders Monday 132 170
Weekday Observed riders Expected riders Monday 132 170 Tuesday 163 Wednesday 223 Thursday 171 Friday 160

26 Bus Ridership test statistic

27 Bus Ridership P-value

28 Reject the null hypothesis.
Bus Ridership P-value When evaluating a one – way table such as the one above, we use k – 1 degrees of freedom. Because there were 5 weekdays, we should calculate the p – value using distribution. P-value = χ2cdf(25.9, 10^10, 4) = What conclusion should we make at the level? Reject the null hypothesis.

29 Example: Desired Vacation Place
The AAA travel agency would like to assess if the distribution of desired vacation place has changed from the model of 3 years ago. A random sample of 928 adults asked, “Name the one place you would want to go for vacation if you had the time and the money.” Hawaii Europe Caribbean Other Three years ago percentage 10% 40% 20% 30% Observed count from poll 124 390 125 289 Expected count under null model

30 Example: Desired Vacation Place
The AAA travel agency would like to assess if the distribution of desired vacation place has changed from the model of 3 years ago. a. Give the null hypothesis to test if there has been a significant change in the distribution of desired vacation place from 3 years ago.

31 Example: Desired Vacation Place
Hawaii Europe Caribbean Other Three years ago percentage 10% 40% 20% 30% Observed count from poll 124 390 125 289 Expected count under null model b. What test statistic value would we expect to see if the null hypothesis were, in fact, true?

32 Example: Desired Vacation Place
Hawaii Europe Caribbean Other Three years ago percentage 10% 40% 20% 30% Observed count from poll 124 390 125 289 Expected count under null model

33 Example: Desired Vacation Place
Hawaii Europe Caribbean Other Three years ago percentage 10% 40% 20% 30% Observed count from poll 124 390 125 289 Expected count under null model

34 Testing For Independence In Two-way Tables
Section 3.4 Testing For Independence In Two-way Tables

35 The Five Steps of the Chi-Squared Test of Independence
Assumptions: Two categorical variables Randomization Expected counts >= 5 in all cells

36 The Five Steps of the Chi-Squared Test of Independence
2. Hypotheses: NULL HYPOTHESIS: The two variables are independent ALTERNATIVE HYPOTHESIS: The two variables are dependent (associated)

37 The Five Steps of the Chi-Squared Test of Independence
3. Test Statistic:

38 The Five Steps of the Chi-Squared Test of Independence

39 Example: Testing For Independence In Two-way Tables
NHANES In recent years, NHANES participants between the ages of 18 and 59 have been asked if they have ever tried marijuana. The responses to this question for randomly selected respondents are summarized by age group in the table below. Tried marijuana Age 18-29 Age 30-39 Age 40-49 Age 50-59 Total Yes 85 61 65 78 289 No 55 40 211 146 116 120 118 500

40 NHANES and marijuana use
Are age and marijuana use independent? As before, we set up a null and alternative hypothesis: H0: Age and marijuana use are independent HA: Age and marijuana use are not independent Because we have two variables, one with more than two levels or categories, we will again use a χ2 test, but the expected counts and _degrees of freedom for the test will be computed differently than with the goodness of fit test.

41 Computing Expected Counts For a Two-way Table

42 NHANES And Marijuana Use
Write the expected count next to the observed count in the table below for each age group and response. Tried marijuana Age 18-29 Age 30-39 Age 40-49 Age 50-59 Total Yes 85 61 65 78 289 No 55 40 211 146 116 120 118 500

43 NHANES And Marijuana Use

44

45 NHANES And Marijuana Use

46 Degrees of Freedom (df)
In order to calculate the p – value , we need to know the degrees of freedom for the χ2 distribution. For a two – way table, this is calculated using the formula: df = (number of rows – 1) x (number of columns – 1) NOTE: The number of rows and number of columns in the formula does not include the total row or column.

47 NHANES And Marijuana Use
Calculate the degrees of freedom and the p – value for the test. Use α = 0.05 to reach a conclusion.

48 Conditions For The χ2 Independence Test
In order for the χ2 independence test to be valid our data must come from a simple random sample and the expected count in each cell of the two-way table must be at least 5. Were the conditions met for the marijuana example?

49 Example: Equal Opportunity Avengers (Self-read Example)
Is being an Avenger equally risky for male and female superheroes? The Avengers is a long-running, popular comic book series (the first issue was published in 1963) and has introduced 173 superhero characters over the years. Many of these characters have died. (Some have died more than once, after returning from their earlier “death(s)” in true comic book fashion.) The table below summarizes the gender of the Avenger and whether or not they have “died” at least once. Gender Died Did not die Total Female 37 21 58 Male 67 48 115 104 69 173

50 Example: Equal Opportunity Avengers (Self-read Example)
Conduct a χ2 – test of independence to determine if “Gender” is independent from “Died”. Treat the Avengers as a random sample. Hypotheses: H0: Gender and Died are independent HA: Gender and Died are not independent

51 Example: Equal Opportunity Avengers (Self-read Example)
Calculate the expected counts and write the expected counts next to the observed counts in the table.

52 Example: Equal Opportunity Avengers (Self-read Example)

53 Example: Equal Opportunity Avengers (Self-read Example)

54 Example: Equal Opportunity Avengers (Self-read Example)

55 Example: Once More With The Weather (Self-read Example)
The National Weather Service maintains a weather station at the Lansing Municipal Airport. Data for the days between January 1, 2015 and November 30, show the following results. Conduct a χ2-test of independence. Compare the p-value to the z-test conducted earlier. Day Type Precipitation No Precipitation Total Weekday 265 235 500 Weekend 119 81 200 384 316 700

56 Solution

57 Solution

58 Thinking Challenge 1 OI3.37Page160
Determine if the statements below are true or false. For each false statement, suggest an alternative wording to make it a true statement. 1. The chi-square distribution, just like the normal distribution, has two parameters, mean and standard deviation. 2. The chi-square distribution is always right skewed, regardless of the value of the degrees of freedom parameter. 3. The chi-square statistic is always positive. 4. As the degrees f freedom increases, the shape of the chi-square distribution becomes more skewed.

59 Thinking Challenge 2OI3.38Page160
Determine if the statements below are true or false. For each false statement, suggest an alternative wording to make it a true statement. 1. As the degree of freedom increases, the mean of the chi-square distribution increases. 2. If you found χ2 = 10 with df = 5, you would fail to reject the Null hypothesis at the 5% significance level. 3. When finding the p – value of a chi-square test, we always shade the tail areas in both tails. 4. As the degree of freedom increases, the variability of the chi-square distribution decreases.

60 Thinking Challenge 3 (OI3.40Page160) Evolution Versus Creationism
A Gallup Poll released in December 2010 asked 1019 adults living in the Continental U.S. about their belief in the origin of humans. These results, along with results from a more comprehensive poll from 2001 (that we sill assume to be exactly accurate), are summarized in the table below.

61 Thinking Challenge 3 (OI3.40Page160)
(a). Calculate the actual number of respondents in that fall in each response category. (b). State hypotheses for the following research question: have beliefs on the origin of human life changed since ? (c). Calculate the expected number of respondents in each category under the condition that the null hypothesis from part (2) is true. (d) Conduct a chi-square test and state your conclusion. (Reminder: verify conditions.)

62 Thinking Challenge 4 (OI3.39Page160) Open Source Textbook

63 Thinking Challenge 5 1. Which of the following is not an assumption or condition that needs to be checked for chi-square tests? Counted Data Randomization Success/Failure Condition Expected Cell Frequency

64 Thinking Challenge 5 2. Which of the following is not true about chi-square models? They are unimodal and right skewed. They can only take on nonnegative values. They have degrees of freedom like t-models, although the degrees of freedom are calculated differently. As the degrees of freedom increase, the chi-square models look more and more like the Normal.

65 Thinking Challenge 5 3. How many degrees of freedom are there for a chi- square test of independence with five rows and six columns? 4 5 20 24 30

66 Thinking Challenge 5 4. The degrees of freedom for chi-square tests grow with the sample size. True False

67 Thinking Challenge 5 5. Goodness of fit tests compare
the observed distribution of a single categorical variable to an expected distribution based on a theory or model. the distribution of several groups for the same categorical variable. counts from a single group for evidence of an association between two categorical variables. None of the above.

68 Thinking Challenge 5 6. Could eye color be a warning signal for hearing loss in patients suffering from meningitis? British researcher Helen Cullington recorded the eye color of 130 deaf patients, and noted whether the patient’s deafness had developed following treatment for meningitis. Her data are summarized in the table below. After setting up the appropriate hypothesis, what is the P-value? 0.15 0.015 0.0015 1.5

69 Thinking Challenge 6

70 Answers: Thinking Challenge 1
1. False: The chi-square distribution has one parameter called degrees of freedom. 2. True 3. True 4. False: As the degrees of freedom increases, the shape of the chi-square distribution becomes more symmetric.

71 Answers: Thinking Challenge 2
1. True 2. True 3. False: The chi-square distribution is right skewed, and the p – value is defined as P(χ2 > χ of observed values), therefore we only shade the right tail. 4. False: The variability increases as the degrees of freedom increases.

72 Answers: Thinking Challenge 3 (OI3.40Page160)

73 Answers: Thinking Challenge 3 (OI3.40Page160)
(b).

74 Answers: Thinking Challenge 3 (OI3.40Page160)

75 Answers: Thinking Challenge 3 (OI3.40Page160)
(d).

76 Answers: Thinking Challenge 4

77 Answers: Thinking Challenge 5
2. D 3. C 4. B 5. A 6. B

78 Answers: Thinking Challenge 6


Download ppt "STT 200 Statistical Methods"

Similar presentations


Ads by Google