STT 200 Statistical Methods

Slides:



Advertisements
Similar presentations
Chapter 11 Other Chi-Squared Tests
Advertisements

Hypothesis Testing IV Chi Square.
© 2010 Pearson Prentice Hall. All rights reserved The Chi-Square Test of Independence.
Copyright © 2014, 2013, 2010 and 2007 Pearson Education, Inc. Chapter Hypothesis Tests Regarding a Parameter 10.
Copyright © 2013, 2010 and 2007 Pearson Education, Inc. Chapter Inference on Categorical Data 12.
Chapter 11 Chi-Square Procedures 11.3 Chi-Square Test for Independence; Homogeneity of Proportions.
Copyright © 2010 Pearson Education, Inc. Slide
© Copyright McGraw-Hill CHAPTER 11 Other Chi-Square Tests.
CHAPTER INTRODUCTORY CHI-SQUARE TEST Objectives:- Concerning with the methods of analyzing the categorical data In chi-square test, there are 2 methods.
1 Chapter 11: Analyzing the Association Between Categorical Variables Section 11.1: What is Independence and What is Association?
Chapter Outline Goodness of Fit test Test of Independence.
Copyright © 2013, 2009, and 2007, Pearson Education, Inc. Chapter 11 Analyzing the Association Between Categorical Variables Section 11.2 Testing Categorical.
Comparing Counts Chapter 26. Goodness-of-Fit A test of whether the distribution of counts in one categorical variable matches the distribution predicted.
Class Seven Turn In: Chapter 18: 32, 34, 36 Chapter 19: 26, 34, 44 Quiz 3 For Class Eight: Chapter 20: 18, 20, 24 Chapter 22: 34, 36 Read Chapters 23 &
Comparing Counts Chi Square Tests Independence.
11.1 Chi-Square Tests for Goodness of Fit
Other Chi-Square Tests
Topics
CHAPTER 26 Comparing Counts.
Chi-Square hypothesis testing
CHAPTER 11 Inference for Distributions of Categorical Data
Chi-square test or c2 test
5.1 INTRODUCTORY CHI-SQUARE TEST
Topics
CHAPTER 11 CHI-SQUARE TESTS
INTRODUCTORY STATISTICS FOR CRIMINAL JUSTICE
Test for Goodness of Fit
Hypothesis Testing Review
Chapter 12 Tests with Qualitative Data
CHAPTER 11 Inference for Distributions of Categorical 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.
Elementary Statistics
Chapter 11 Goodness-of-Fit and Contingency Tables
Inference on Categorical Data
Elementary Statistics
AP Stats Check In Where we’ve been… Chapter 7…Chapter 8…
Chi Square Two-way Tables
Elementary Statistics
AP Stats Check In Where we’ve been… Chapter 7…Chapter 8…
Chapter 11: Inference for Distributions of Categorical Data
Two Categorical Variables: The Chi-Square Test
CHAPTER 11 Inference for Distributions of Categorical Data
Chapter 10 Analyzing the Association Between Categorical Variables
Contingency Tables: Independence and Homogeneity
Chapter 13 Goodness-of-Fit Tests and Contingency Analysis
STT 200 Statistical Methods
Overview and Chi-Square
15.1 Goodness-of-Fit Tests
Inference on Categorical Data
Lecture 41 Section 14.1 – 14.3 Wed, Nov 14, 2007
CHAPTER 11 Inference for Distributions of Categorical Data
Lesson 11 - R Chapter 11 Review:
Paired Samples and Blocks
Analyzing the Association Between Categorical Variables
CHAPTER 11 CHI-SQUARE TESTS
Hypothesis Tests for a Standard Deviation
Chapter 26 Comparing Counts.
Chapter 13: Inference for Distributions of Categorical Data
CHAPTER 11 Inference for Distributions of Categorical Data
CHAPTER 11 Inference for Distributions of Categorical Data
Copyright © Cengage Learning. All rights reserved.
CHAPTER 11 Inference for Distributions of Categorical Data
Chapter 26 Comparing Counts Copyright © 2009 Pearson Education, Inc.
CHAPTER 11 Inference for Distributions of Categorical Data
CHAPTER 11 Inference for Distributions of Categorical Data
Chapter 13 Goodness-of-Fit Tests and Contingency Analysis
Chapter 26 Comparing Counts.
CHAPTER 11 Inference for Distributions of Categorical Data
CHAPTER 11 Inference for Distributions of Categorical Data
Presentation transcript:

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

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.

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.

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.

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.

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.

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.

  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

Bus Ridership

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.

Bus Ridership

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

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.

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.

 

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

   

   

  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.

  What would this test statistic be for the other days?

  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.

 

Degrees of Freedom  

  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

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

Bus Ridership test statistic

Bus Ridership P-value  

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) = 0.0000331 What conclusion should we make at the level? Reject the null hypothesis.

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

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.

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?

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  

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  

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

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

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)

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

The Five Steps of the Chi-Squared Test of Independence

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 500 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

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.

Computing Expected Counts For a Two-way Table  

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

NHANES And Marijuana Use

   

NHANES And Marijuana Use

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.

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

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?

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

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

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

Example: Equal Opportunity Avengers (Self-read Example)

Example: Equal Opportunity Avengers (Self-read Example)

Example: Equal Opportunity Avengers (Self-read Example)

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 700 days between January 1, 2015 and November 30, 2016 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

Solution

Solution

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.

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.

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.

Thinking Challenge 3 (OI3.40Page160) (a). Calculate the actual number of respondents in 2010 that fall in each response category. (b). State hypotheses for the following research question: have beliefs on the origin of human life changed since 2001? (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.)

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

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

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.

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

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

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.

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

Thinking Challenge 6

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.

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 > χ2 of observed values), therefore we only shade the right tail. 4. False: The variability increases as the degrees of freedom increases.

Answers: Thinking Challenge 3 (OI3.40Page160)

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

Answers: Thinking Challenge 3 (OI3.40Page160)

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

Answers: Thinking Challenge 4

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

Answers: Thinking Challenge 6