text
stringlengths 235
3.08k
|
---|
confidence level is that if many samples of the same size were taken from the population, about 95% of the resulting confidence intervals would capture the true population parameter (assuming the conditions are met and the probability model is true). Note that this is a relative frequency interpretation. • We cannot use the language of probability to interpret an individual confidence interval, once it has been calculated. The confidence level tells us what percent of the intervals will capture the population parameter, not the probability that a calculated interval captures the population parameter. Each calculated interval either does or does not capture the population parameter. Margin of error • Confidence intervals are often reported as: point estimate ± margin of error. The margin of error (M E) = critical value × SE of estimate, and it tells us, with a particular confidence, how much we expect our point estimate to deviate from the true population value due to chance. • The margin of error depends on the confidence level ; the standard error does not. Other things being constant, a higher confidence level leads to a larger margin of error. • For a fixed confidence level, increasing the sample size decreases the margin of error. This assumes a random sample. • The margin of error formula only applies if a sample is random. Moreover, the margin of error measures only sampling error ; it does not account for additional error introduced by response bias and non-response bias. Even with a perfectly random sample, the actual error in a poll is likely higher than the reported margin of error.11 10We explain the relationship between z and t in Chapter 7 11nytimes.com/2016/10/06/upshot/when-you-hear-the-margin-of-error-is-plus-or-minus-3-percent-think-7- instead.html 5.2. CONFIDENCE INTERVALS 271 Exercises 5.7 Chronic illness, Part I. In 2013, the Pew Research Foundation reported that “45% of U.S. adults report that they live with one or more chronic conditions”.12 However, this value was based on a sample, so it may not be a perfect estimate for the population parameter of interest on its own. The study reported a standard error of about 1.2%, and
|
a normal model may reasonably be used in this setting. Create a 95% confidence interval for the proportion of U.S. adults who live with one or more chronic conditions. Also interpret the confidence interval in the context of the study. 5.8 Twitter users and news, Part I. A poll conducted in 2013 found that 52% of U.S. adult Twitter users get at least some news on Twitter.13. The standard error for this estimate was 2.4%, and a normal distribution may be used to model the sample proportion. Construct a 99% confidence interval for the fraction of U.S. adult Twitter users who get some news on Twitter, and interpret the confidence interval in context. 5.9 Waiting at an ER, Part I. A hospital administrator hoping to improve wait times decides to estimate the average emergency room waiting time at her hospital. She collects a simple random sample of 64 patients and determines the time (in minutes) between when they checked in to the ER until they were first seen by a doctor. A 95% confidence interval based on this sample is (128 minutes, 147 minutes), which is based on the normal model for the mean. Determine whether the following statements are true or false, and explain your reasoning. (a) We are 95% confident that the average waiting time of these 64 emergency room patients is between 128 and 147 minutes. (b) We are 95% confident that the average waiting time of all patients at this hospital’s emergency room is between 128 and 147 minutes. (c) 95% of random samples have a sample mean between 128 and 147 minutes. (d) A 99% confidence interval would be narrower than the 95% confidence interval since we need to be more sure of our estimate. (e) The margin of error is 9.5 and the sample mean is 137.5. (f) In order to decrease the margin of error of a 95% confidence interval to half of what it is now, we would need to double the sample size. 5.10 Mental health. The General Social Survey asked the question: “For how many days during the past 30 days was your mental health, which includes stress, depression, and problems with emotions, not good?” Based on responses
|
from 1,151 US residents, the survey reported a 95% confidence interval of 3.40 to 4.24 days in 2010. (a) Interpret this interval in context of the data. (b) What does “95% confident” mean? Explain in the context of the application. (c) Suppose the researchers think a 99% confidence level would be more appropriate for this interval. Will this new interval be smaller or wider than the 95% confidence interval? (d) If a new survey were to be done with 500 Americans, do you think the standard error of the estimate be larger, smaller, or about the same. 12Pew Research Center, Washington, D.C. The Diagnosis Difference, November 26, 2013. 13Pew Research Center, Washington, D.C. Twitter News Consumers: Young, Mobile and Educated, November 4, 2013. 272 CHAPTER 5. FOUNDATIONS FOR INFERENCE 5.11 Cyberbullying rates. Teens were surveyed about cyberbullying, and 54% to 64% reported experiencing cyberbullying (95% confidence interval).14 Answer the following questions based on this interval. (a) A newspaper claims that a majority of teens have experienced cyberbullying. Is this claim supported by the confidence interval? Explain your reasoning. (b) A researcher conjectured that 70% of teens have experienced cyberbullying. Is this claim supported by the confidence interval? Explain your reasoning. (c) Without actually calculating the interval, determine if the claim of the researcher from part (b) would be supported based on a 90% confidence interval? 5.12 Waiting at an ER, Part II. Exercise 5.9 provides a 95% confidence interval for the mean waiting time at an emergency room (ER) of (128 minutes, 147 minutes). Answer the following questions based on this interval. (a) A local newspaper claims that the average waiting time at this ER exceeds 3 hours. Is this claim supported by the confidence interval? Explain your reasoning. (b) The Dean of Medicine at this hospital claims the average wait time is 2.2 hours. Is this claim supported by the confidence interval? Explain your reasoning. (c) Without actually calculating the
|
interval, determine if the claim of the Dean from part (b) would be supported based on a 99% confidence interval? 14Pew Research Center, A Majority of Teens Have Experienced Some Form of Cyberbullying. September 27, 2018. 5.3. INTRODUCING HYPOTHESIS TESTING 273 5.3 Introducing hypothesis testing In an experiment, one treatment reduces cholesterol by 10% while another treatment reduces it by 17%. Is this strong enough evidence that the second treatment is more effective? In this section, we will set up a framework for answering questions such as this and will look at the different types of decision errors that researcher can make when drawing conclusions based on data. Learning objectives 1. Explain the logic of hypothesis testing, including setting up hypotheses and drawing a conclu- sion based on the set significance level and the calculated p-value. 2. Set up the null and alternative hypothesis in words and in terms of population parameters. 3. Interpret a p-value in context and recognize how the calculation of the p-value depends upon the direction of the alternative hypothesis. 4. Define and interpret the concept statistically significant. 5. Interpret Type I, Type II Error, and power in the context of hypothesis testing. 6. Distinguish between statistically significant and practically significant, and recognize the role that sample size plays here. 7. Understand the two general conditions for when the confidence interval and hypothesis testing procedures apply and explain why these conditions are necessary. 5.3.1 Case study: medical consultant People providing an organ for donation sometimes seek the help of a special medical consultant. These consultants assist the patient in all aspects of the surgery, with the goal of reducing the possibility of complications during the medical procedure and recovery. Patients might choose a consultant based in part on the historical complication rate of the consultant’s clients. One consultant tried to attract patients by noting the overall complication rate for liver donor surgeries in the US is about 10%, but her clients have had only 9 complications in the 142 liver donor surgeries she has facilitated. She claims this is strong evidence that her work meaningfully contributes to reducing complications (and therefore she should be hired!). EXAMPLE 5.21 We will let p represent the true complication rate for liver donors working with this consultant.
|
Calculate the best estimate for p using the data. Label the point estimate as ˆp. The sample proportion for the complication rate is 9 complications divided by the 142 surgeries the consultant has worked on: ˆp = 9/142 = 0.063. EXAMPLE 5.22 Is it possible to prove that the consultant’s work reduces complications? No. The claim implies that there is a causal connection, but the data are observational. For example, maybe patients who can afford a medical consultant can afford better medical care, which can also lead to a lower complication rate. 274 CHAPTER 5. FOUNDATIONS FOR INFERENCE EXAMPLE 5.23 While it is not possible to assess the causal claim, it is still possible to ask whether the low complication rate of ˆp = 0.063 provides evidence that the consultant’s true complication rate is different than the US complication rate. Why might we be tempted to immediately conclude that the consultant’s true complication rate is different than the US complication rate? Can we draw this conclusion? Her sample complication rate is ˆp = 0.063, which is 0.037 lower than the US complication rate of 10%. However, we cannot yet be sure if the observed difference represents a real difference or is just the result of random variation. We wouldn’t expect the sample proportion to be exactly 0.10, even if the truth was that her real complication rate was 0.10. 5.3.2 Setting up the null and alternative hypothesis We can set up two competing hypotheses about the consultant’s true complication rate. The first is call the null hypothesis and represents either a skeptical perspective or a perspective of no difference. The second is called the alternative hypothesis (or alternative hypothesis) and represents a new perspective such as the possibility that there has been a change or that there is a treatment effect in an experiment. NULL AND ALTERNATIVE HYPOTHESES The null hypothesis is abbreviated H0. It represents a skeptical perspective and is often a claim of no change or no difference. The alternative hypothesis is abbreviated HA. It is the claim researchers hope to prove or find evidence for, and it often asserts that there has been a change or an eff
|
ect. Our job as data scientists is to play the skeptic: before we buy into the alternative hypothesis, we need to see strong supporting evidence. EXAMPLE 5.24 Identify the null and alternative claim regarding the consultant’s complication rate. H0: The true complication rate for the consultant’s clients is the same as the US complication rate of 10%. HA: The true complication rate for the consultant’s clients is different than 10%. Often it is convenient to write the null and alternative hypothesis in mathematical or numerical terms. To do so, we must first identify the quantity of interest. This quantity of interest is known as the parameter for a hypothesis test. PARAMETERS AND POINT ESTIMATES A parameter for a hypothesis test is the “true” value of the population of interest. When the parameter is a proportion, we call it p. A point estimate is calculated from a sample. When the point estimate is a proportion, we call it ˆp. The observed or sample proportion of 0.063 is a point estimate for the true proportion. The parameter in this problem is the true proportion of complications for this consultant’s clients. The parameter is unknown, but the null hypothesis is that it equals the overall proportion of complications: p = 0.10. This hypothesized value is called the null value. 5.3. INTRODUCING HYPOTHESIS TESTING 275 NULL VALUE OF A HYPOTHESIS TEST The null value is the value hypothesized for the parameter in H0, and it is sometimes represented with a subscript 0, e.g. p0 (just like H0). In the medical consultant case study, the parameter is p and the null value is p0 = 0.10. We can write the null and alternative hypothesis as numerical statements as follows. • H0: p = 0.10 (The complication rate for the consultant’s clients is equal to the US complication rate of 10%.) • HA: p = 0.10 (The complication rate for the consultant’s clients is not equal to the US complication rate of 10%.) HYPOTHESIS TESTING These hypotheses are part of what is called a hypothesis test. A hypothesis test is a statistical technique used to evaluate competing claims using data. Often times, the null hypothesis takes a stance of no difference or no effect. If the null hypothesis
|
and the data notably disagree, then we will reject the null hypothesis in favor of the alternative hypothesis. Don’t worry if you aren’t a master of hypothesis testing at the end of this section. We’ll discuss these ideas and details many times in this chapter and the two chapters that follow. The null claim is always framed as an equality: it tells us what quantity we should use for the parameter when carrying out calculations for the hypothesis test. There are three choices for the alternative hypothesis, depending upon whether the researcher is trying to prove that the value of the parameter is greater than, less than, or not equal to the null value. ALWAYS WRITE THE NULL HYPOTHESIS AS AN EQUALITY We will find it most useful if we always list the null hypothesis as an equality (e.g. p = 7) while the alternative always uses an inequality (e.g. p = 0.7, p > 0.7, or p < 0.7). GUIDED PRACTICE 5.25 According to the 2010 US Census, 7.6% of residents in the state of Alaska were under 5 years old. A researcher plans to take a random sample of residents from Alaska to test whether or not this is still the case. Write out the hypotheses that the researcher should test in both plain and statistical language.15 When the alternative claim uses a =, we call the test a two-sided test, because either extreme provides evidence against H0. When the alternative claim uses a < or a >, we call it a one-sided test. ONE-SIDED AND TWO-SIDED TESTS If the researchers are only interested in showing an increase or a decrease, but not both, use a one-sided test. If the researchers would be interested in any difference from the null value – an increase or decrease – then the test should be two-sided. 15H0: p = 0.076; The proportion of residents under 5 years old in Alaska is unchanged from 2010. HA: p = 0.076; The proportion of residents under 5 years old in Alaska has changed from 2010. Note that it could have increased or decreased. 276 CHAPTER 5. FOUNDATIONS FOR INFERENCE EXAMPLE 5.26 For the example of the consultant’s complication rate, we knew that her sample complication rate was 0.063, which was lower than the US complication rate of 0.10
|
. Why did we conduct a two-sided hypothesis test for this setting? The setting was framed in the context of the consultant being helpful, but what if the consultant actually performed worse than the US complication rate? Would we care? More than ever! Since we care about a finding in either direction, we should run a two-sided test. ONE-SIDED HYPOTHESES ARE ALLOWED ONLY BEFORE SEEING DATA After observing data, it is tempting to turn a two-sided test into a one-sided test. Avoid this temptation. Hypotheses must be set up before observing the data. If they are not, the test must be two-sided. 5.3.3 Evaluating the hypotheses with a p-value EXAMPLE 5.27 There were 142 patients in the consultant’s sample. If the null claim is true, how many would we expect to have had a complication? If the null claim is true, we would expect about 10% of the patients, or about 14.2 to have a complication. The consultant’s complication rate for her 142 clients was 0.063 (0.063 × 142 ≈ 9). What is the probability that a sample would produce a number of complications this far from the expected value of 14.2, if her true complication rate were 0.10, that is, if H0 were true? The probability, which is estimated in Section 5.7 on page 276, is about 0.1754. We call this quantity the p-value. Figure 5.7: The shaded area represents the p-value. We observed ˆp = 0.063, so any observations smaller than this are at least as extreme relative to the null value, p0 = 0.1, and so the lower tail is shaded. However, since this is a two-sided test, values above 0.137 are also at least as extreme as 0.063 (relative to 0.1), and so they also contribute to the p-value. The tail areas together total of about 0.1754 when calculated using a simulation technique in Section 5.3.4. Sample Proportions Under the Null Hypothesis0.020.050.070.10.130.150.18 5.3. INTRODUCING HYPOTHESIS TESTING 277 Figure 5.8: When the alternative hypothesis takes the form p < null value, the p
|
-value is represented by the lower tail. When it takes the form p > null value, the p-value is represented by the upper tail. When using p = null value, then the p-value is represented by both tails. FINDING AND INTERPRETING THE P-VALUE We find and interpret the p-value according to the nature of the alternative hypothesis. HA: parameter > null value. The p-value corresponds to the area in the upper tail and is probability of getting a test statistic larger than the observed test statistic if the null hypothesis is true and the probability model is accurate. HA: parameter < null value. The p-value corresponds to the area in the lower tail and is the probability of observing a test statistic smaller than the observed test statistic if the null hypothesis is true and the probability model is accurate. HA: parameter = null value. The p-value corresponds to the area in both tails and is the probability of observing a test statistic larger in magnitude than the observed test statistic if the null hypothesis is true and the probability model is accurate. More generally, we can say that the p-value is the probability of getting a test statistic as extreme or more extreme than the observed test statistic in the direction of HA if the null hypothesis is true and the probability model is accurate. When working with proportions, we can also say that the p-value is the probability of getting a sample proportion as far from or farther from the null proportion in the direction of HA if the null hypothesis is true and the normal model holds. When the p-value is small, i.e. less than a previously set threshold, we say the results are statistically significant. This means the data provide such strong evidence against H0 that we reject the null hypothesis in favor of the alternative hypothesis. The threshold is called the significance level and is represented by α (the Greek letter alpha). The significance level is typically set to α = 0.05, but can vary depending on the field or the application. STATISTICAL SIGNIFICANCE If the p-value is less than the significance level α (usually 0.05), we say that the result is statistically significant. We reject H0, and we have strong evidence favoring HA. If the p-value is greater than the significance level α, we say that
|
the result is not statistically significant. We do not reject H0, and we do not have strong evidence for HA. Recall that the null claim is the claim of no difference. If we reject H0, we are asserting that there is a real difference. If we do not reject H0, we are saying that the null claim is reasonable, but we are not saying that the null claim has been proven. GUIDED PRACTICE 5.28 Because the p-value is 0.1754, which is larger than the significance level 0.05, we do not reject the null hypothesis. Explain what this means in the context of the problem using plain language.16 16The data do not provide evidence that the consultant’s complication rate is significantly lower or higher than the US complication rate of 10%. HA: p<null valueHA: p>null valueHA: p„null value 278 CHAPTER 5. FOUNDATIONS FOR INFERENCE EXAMPLE 5.29 In the previous exercise, we did not reject H0. This means that we did not disprove the null claim. Is this equivalent to proving the null claim is true? No. We did not prove that the consultant’s complication rate is exactly equal to 10%. Recall that the test of hypothesis starts by assuming the null claim is true. That is, the test proceeds as an argument by contradiction. If the null claim is true, there is a 0.1754 chance of seeing sample data as divergent from 10% as we saw in our sample. Because 0.1754 is large, it is within the realm of chance error, and we cannot say the null hypothesis is unreasonable.17 DOUBLE NEGATIVES CAN SOMETIMES BE USED IN STATISTICS In many statistical explanations, we use double negatives. For instance, we might say that the null hypothesis is not implausible or we failed to reject the null hypothesis. Double negatives are used to communicate that while we are not rejecting a position, we are also not saying that we know it to be true. EXAMPLE 5.30 Does the conclusion in Guided Practice 5.28 ensure that there is no real association between the surgical consultant’s work and the risk of complications? Explain. No. It is possible that the consultant’s work is associated with a lower or higher risk of complications
|
. If this was the case, the sample may have been too small to reliable detect this effect. EXAMPLE 5.31 An experiment was conducted where study participants were randomly divided into two groups. Both were given the opportunity to purchase a DVD, but one half was reminded that the money, if not spent on the DVD, could be used for other purchases in the future, while the other half was not. The half that was reminded that the money could be used on other purchases was 20% less likely to continue with a DVD purchase. We determined that such a large difference would only occur about 1-in-150 times if the reminder actually had no influence on student decision-making. What is the p-value in this study? Was the result statistically significant? The p-value was 0.006 (about 1/150). Since the p-value is less than 0.05, the data provide statistically significant evidence that US college students were actually influenced by the reminder. WHAT’S SO SPECIAL ABOUT 0.05? We often use a threshold of 0.05 to determine whether a result is statistically significant. But why 0.05? Maybe we should use a bigger number, or maybe a smaller number. If you’re a little puzzled, that probably means you’re reading with a critical eye – good job! We’ve made a video to help clarify why 0.05 : www.openintro.org/why05 Sometimes it’s a good idea to deviate from the standard. We’ll discuss when to choose a threshold different than 0.05 in Section 5.3.7. Statistical inference is the practice of making decisions and conclusions from data in the context of uncertainty. Just as a confidence interval may occasionally fail to capture the true value of the parameter, a test of hypothesis may occasionally lead us to an incorrect conclusion. While a given data set may not always lead us to a correct conclusion, statistical inference gives us tools to control and evaluate how often these errors occur. 17The p-value is a conditional probability. It is P(getting data at least as divergent from the null value as we observed | H0 is true). It is NOT P( H0 is true | we got data this divergent from the null
|
value). 5.3. INTRODUCING HYPOTHESIS TESTING 279 5.3.4 Calculating the p-value by simulation (special topic) When conditions for the applying a normal model are met, we use a normal model to find the p-value of a test of hypothesis. In the complication rate example, the distribution is not normal. It is, however, binomial, because we are interested in how many out of 142 patients will have complications. We could calculate the p-value of this test using binomial probabilities. A more general approach, though, for calculating p-values when a normal model does not apply is to use what is known as simulation. While performing this procedure is outside of the scope of the course, we provide an example here in order to better understand the concept of a p-value. We simulate 142 new patients to see what result might happen if the complication rate really is 0.10. To do this, we could use a deck of cards. Take one red card, nine black cards, and mix them up. If the cards are well-shuffled, drawing the top card is one way of simulating the chance if the card is red, we say the patient had a a patient has a complication if the true rate is 0.10: If we repeat this complication, and if it is black then we say they did not have a complication. process 142 times and compute the proportion of simulated patients with complications, ˆpsim, then this simulated proportion is exactly a draw from the null distribution. There were 12 simulated cases with a complication and 130 simulated cases without a compli- cation: ˆpsim = 12/142 = 0.085. One simulation isn’t enough to get a sense of the null distribution, so we repeated the simulation 10,000 times using a computer. Figure 5.9 shows the null distribution from these 10,000 simulations. The simulated proportions that are less than or equal to ˆp = 0.063 are shaded. There were 0.0877 simulated sample proportions with ˆpsim ≤ 0.063, which represents a fraction 0.0877 of our simulations: left tail = Number of observed simulations with ˆpsim ≤ 0.063 10000 = 877 10000 = 0.0877 However, this is not our p-value! Remember that we are conducting a two-sided test,
|
so we should double the one-tail area to get the p-value:18 p-value = 2 × left tail = 2 × 0.0877 = 0.1754 Figure 5.9: The null distribution for ˆp, created from 10,000 simulated studies. The left tail contains 8.77% of the simulations. For a two-sided test, we double the tail area to get the p-value. This doubling accounts for the observations we might have observed in the upper tail, which are also at least as extreme (relative to 0.10) as what we observed, ˆp = 0.063. 18This doubling approach is preferred even when the distribution isn’t symmetric, as in this case. p^sim 0.000.050.100.150.2002004006008001000Observations over hereare just as extreme,so they should also counttowards the p−valueNumber of Simulations 280 CHAPTER 5. FOUNDATIONS FOR INFERENCE 5.3.5 Hypothesis testing: a five step process Use a hypothesis test to test H0 versus HA at a particular signficance level, α. (AP EXAM TIP) WHEN CARRYING OUT A HYPOTHESIS TEST PROCEDURE, FOLLOW THESE FIVE STEPS: • Identify: Identify the hypotheses and the significance level. • Choose: Choose the appropriate test procedure and identify it by name. • Check: Check that the conditions for the test procedure are met. • Calculate: Calculate the test statistic and the p-value. test statistic = point estimate − null value SE of estimate • Conclude: Compare the p-value to the significance level to determine whether to reject H0 or not reject H0. Draw a conclusion in the context of HA. 5.3.6 Decision errors The hypothesis testing framework is a very general tool, and we often use it without a second thought. If a person makes a somewhat unbelievable claim, we are initially skeptical. However, if there is sufficient evidence that supports the claim, we set aside our skepticism. The hallmarks of hypothesis testing are also found in the US court system. EXAMPLE 5.32 A US court considers two possible claims about a defendant: she is either innocent or guilty. If we set these claims up in a hypothesis framework,
|
which would be the null hypothesis and which the alternative? The jury considers whether the evidence is so convincing (strong) that there is evidence beyond a reasonable doubt of the person’s guilt. That is, the starting assumption (null hypothesis) is that the person is innocent until evidence is presented that convinces the jury that the person is guilty (alternative hypothesis). In statistics, our evidence comes in the form of data, and we use the significance level to decide what is beyond a reasonable doubt. Jurors examine the evidence to see whether it convincingly shows a defendant is guilty. Notice that a jury finds a defendant either guilty or not guilty. They either reject the null claim or they do not reject the null claim. They never prove the null claim, that is, they never find the defendant innocent. If a jury finds a defendant not guilty, this does not necessarily mean the jury is confident in the person’s innocence. They are simply not convinced of the alternative that the person is guilty. This is also the case with hypothesis testing: even if we fail to reject the null hypothesis, we typically do not accept the null hypothesis as truth. Failing to find strong evidence for the alternative hypothesis is not equivalent to providing evidence that the null hypothesis is true. Hypothesis tests are not flawless. Just think of the court system: innocent people are sometimes wrongly convicted and the guilty sometimes walk free. Similarly, data can point to the wrong conclusion. However, what distinguishes statistical hypothesis tests from a court system is that our framework allows us to quantify and control how often the data lead us to the incorrect conclusion. There are two competing hypotheses: the null and the alternative. In a hypothesis test, we make a statement about which one might be true, but we might choose incorrectly. There are four possible scenarios in a hypothesis test, which are summarized in Figure 5.10. 5.3. INTRODUCING HYPOTHESIS TESTING 281 Test conclusion Truth H0 true HA true do not reject H0 correct conclusion reject H0 in favor of HA Type I Error Type II Error correct conclusion Figure 5.10: Four different scenarios for hypothesis tests. TYPE I AND TYPE II ERRORS A Type I Error is rejecting H0 when H0 is actually true. When we reject the null hypothesis, it is possible that we make a Type I Error.
|
A Type II Error is failing to reject H0 when HA is actually true. When we dod not reject the null hypothesis, it is possible that we make a Type II Error. EXAMPLE 5.33 In a US court, the defendant is either innocent (H0) or guilty (HA). What does a Type I Error represent in this context? What does a Type II Error represent? Figure 5.10 may be useful. If the court makes a Type I Error, this means the defendant is innocent (H0 true) but wrongly convicted. A Type II Error means the court failed to reject H0 (i.e. failed to convict the person) when they were in fact guilty (HA true). EXAMPLE 5.34 How could we reduce the Type I Error rate in US courts? What influence would this have on the Type II Error rate? To lower the Type I Error rate, we might raise our standard for conviction from “beyond a reasonable doubt” to “beyond a conceivable doubt” so fewer people would be wrongly convicted. However, this would also make it more difficult to convict the people who are actually guilty, so we would make more Type II Errors. GUIDED PRACTICE 5.35 How could we reduce the Type II Error rate in US courts? What influence would this have on the Type I Error rate?19 GUIDED PRACTICE 5.36 A group of women bring a class action lawsuit that claims discrimination in promotion rates. What would a Type I Error represent in this context?20 These examples provide an important lesson: if we reduce how often we make one type of error, we generally make more of the other type. 19To lower the Type II Error rate, we want to convict more guilty people. We could lower the standards for conviction from “beyond a reasonable doubt” to “beyond a little doubt”. Lowering the bar for guilt will also result in more wrongful convictions, raising the Type I Error rate. 20We must first identify which is the null hypothesis and which is the alternative. The alternative hypothesis is the one that bears the burden of proof, so the null hypothesis is that there was no discrimination and the alternative hypothesis is that there was discrimination. Making a Type I Error in this context would mean that in fact there was no discrimination, even though we concluded that women were discriminated against. Notice that this
|
does not necessarily mean something was wrong with the data or that we made a computational mistake. Sometimes data simply point us to the wrong conclusion, which is why scientific studies are often repeated to check initial findings. 282 CHAPTER 5. FOUNDATIONS FOR INFERENCE 5.3.7 Choosing a significance level If H0 is true, what is the probability that we will incorrectly reject it? In hypothesis testing, we perform calculations under the premise that H0 is true, and we reject H0 if the p-value is smaller than the significance level α. That is, α is the probability of making a Type I Error. The choice of what to make α is not arbitrary. It depends on the gravity of the consequences of a Type I Error. RELATIONSHIP BETWEEN TYPE I AND TYPE II ERRORS The probability of a Type I Error is called α and corresponds to the significance level of a test. The probability of a Type II Error is called β. As we make α smaller, β typically gets larger, and vice versa. EXAMPLE 5.37 If making a Type I Error is especially dangerous or especially costly, should we choose a smaller significance level or a higher significance level? Under this scenario, we want to be very cautious about rejecting the null hypothesis, so we demand very strong evidence before we are willing to reject the null hypothesis. Therefore, we want a smaller significance level, maybe α = 0.01. EXAMPLE 5.38 If making a Type II Error is especially dangerous or especially costly, should we choose a smaller significance level or a higher significance level? We should choose a higher significance level (e.g. 0.10). Here we want to be cautious about failing to reject H0 when the null is actually false. SIGNIFICANCE LEVELS SHOULD REFLECT CONSEQUENCES OF ERRORS The significance level selected for a test should reflect the real-world consequences associated with making a Type I or Type II Error. If a Type I Error is very dangerous, make α smaller. 5.3.8 Statistical power of a hypothesis test When the alternative hypothesis is true, the probability of not making a
|
Type II Error is called power. It is common for researchers to perform a power analysis to ensure their study collects enough data to detect the effects they anticipate finding. As you might imagine, if the effect they care about is small or subtle, then if the effect is real, the researchers will need to collect a large sample size in order to have a good chance of detecting the effect. However, if they are interested in large effect, they need not collect as much data. The Type II Error rate β and the magnitude of the error for a point estimate are controlled by the sample size. As the sample size n goes up, the Type II Error rate goes down, and power goes up. Real differences from the null value, even large ones, may be difficult to detect with small samples. However, if we take a very large sample, we might find a statistically significant difference but the size of the difference might be so small that it is of no practical value. 5.3. INTRODUCING HYPOTHESIS TESTING 283 5.3.9 Statistical significance versus practical significance When the sample size becomes larger, point estimates become more precise and any real differences in the mean and null value become easier to detect and recognize. Even a very small difference would likely be detected if we took a large enough sample. Sometimes researchers will take such large samples that even the slightest difference is detected. While we still say that difference is statistically significant, it might not be practically significant. Statistically significant differences are sometimes so minor that they are not practically relevant. This is especially important to research: if we conduct a study, we want to focus on finding a meaningful result. We don’t want to spend lots of money finding results that hold no practical value. The role of a data scientist in conducting a study often includes planning the size of the study. The data scientist might first consult experts or scientific literature to learn what would be the smallest meaningful di
|
fference from the null value. She also would obtain some reasonable estimate for the standard deviation. With these important pieces of information, she would choose a sufficiently large sample size so that the power for the meaningful difference is perhaps 80% or 90%. While larger sample sizes may still be used, she might advise against using them in some cases, especially in sensitive areas of research. 5.3.10 Statistical significance versus a real difference When a result is statistically significant at the α = 0.05 level, we have evidence that the result is real. However, when there is no difference or effect, we can expect that 5% of the time the test conclusion will lead to a Type I Error and incorrectly reject the null hypothesis. Therefore we must beware of what is called p-hacking, in which researchers may test many, many hypotheses and then publish the ones that come out statistically significant. As we noted, we can expect 5% of the results to be significant when the null hypothesis is true and there really is no difference or effect.21 5.3.11 When to retreat We must point out that statistical tools rely on conditions. When the conditions are not met, these tools are unreliable and drawing conclusions from them is treacherous. The conditions for these tools typically come in two forms. • The individual observations must be independent. A random sample from less than 10% of the population ensures the observations are independent. In experiments, we generally require that subjects are randomized into groups. If independence fails, then advanced techniques must be used, and in some such cases, inference may not be possible. • Other conditions focus on sample size and skew. For example, in Chapter 4 we looked at the success-failure condition and sample size condition for when ˆp and ¯x will follow a nearly normal distribution. Verification of conditions for statistical tools is always necessary. When conditions are not satisfied for a given statistical technique, it is necessary to investigate new methods that are appropriate for the data. Finally, we caution that there may be no inference tools helpful when considering data that include unknown biases, such as convenience samples. For this reason, there are books, courses, and researchers devoted to the techniques of sampling and experimental design. See Sections 1
|
.3-1.5 for basic principles of data collection. 21 The problem is even greater than p-hacking. In what has been called the “reproducibility crisis”, researchers have failed to reproduce a large proportion of results that were found significant and were published in scientific journals. This problem highlights the importance of research that reproduces earlier work rather than taking the word of a single study. Also keep in mind that the probability that a difference will be found to be significant given that there is no real difference is not the same as the probability that a difference is not real, given that it was found significant. Depending upon the veracity of the hypotheses tested, the latter can be upwards of 80%, leading some to assert that “most published research is false”. https://www.economist.com/briefing/2013/10/18/trouble-at-the-lab 284 CHAPTER 5. FOUNDATIONS FOR INFERENCE Section summary • A hypothesis test is a statistical technique used to evaluate competing claims based on data. • The competing claims are called hypotheses and are often about population parameters (e.g. µ and p); they are never about sample statistics. – The null hypothesis is abbreviated H0. It represents a skeptical perspective or a per- spective of no difference or no change. – The alternative hypothesis is abbreviated HA. It represents a new perspective or a perspective of a real difference or change. Because the alternative hypothesis is the stronger claim, it bears the burden of proof. • The logic of a hypothesis test: In a hypothesis test, we begin by assuming that the null hypothesis is true. Then, we calculate how unlikely it would be to get a sample value as extreme as we actually got in our sample, assuming that the null value is correct. If this likelihood is too small, it casts doubt on the null hypothesis and provides evidence for the alternative hypothesis. • We set a significance level, denoted α, which represents the threshold below which we will reject the null hypothesis. The most common significance level is α = 0.05. If we require more evidence to reject the null hypothesis, we use a smaller α. • After verifying that the relevant conditions are
|
met, we can calculate the test statistic. The test statistic tells us how many standard errors the point estimate (sample value) is from the null value (i.e. the value hypothesized for the parameter in the null hypothesis). When investigating a single mean or proportion or a difference of means or proportions, the test statistic is calculated as: point estimate − null value. SE of estimate • After the test statistic, we calculate the p-value. We find and interpret the p-value according to the nature of the alternative hypothesis. The three possibilities are: HA: parameter > null value. The p-value corresponds to the area in the upper tail. HA: parameter < null value. The p-value corresponds to the area in the lower tail. HA: parameter = null value. The p-value corresponds to the area in both tails. The p-value is the probability of getting a test statistic as extreme or more extreme than the observed test statistic in the direction of HA if the null hypothesis is true and the probability model is accurate. • The conclusion or decision of a hypothesis test is based on whether the p-value is smaller or larger than the preset significance level α. – When the p-value < α, we say the results are statistically significant at the α level and we have evidence of a real difference or change. The observed difference is beyond what would have been expected from chance variation alone. This leads us to reject H0 and gives us evidence for HA. – When the p-value > α, we say the results are not statistically significant at the α level and we do not have evidence of a real difference or change. The observed difference was within the realm of expected chance variation. This leads us to not reject H0 and does not give us evidence for HA. • Decision errors. In a hypothesis test, there are two types of decision errors that could be made. These are called Type I and Type II Errors. – A Type I Error is rejecting H0, when H0 is actually true. We commit a Type I Error if we call a result significant when there is no real difference or effect. P(Type I Error) = α. – A Type II Error is not rejecting H0, when HA is actually
|
true. We commit a Type II Error if we call a result not significant when there is a real difference or effect. P(Type II Error) = β. 5.3. INTRODUCING HYPOTHESIS TESTING 285 – The probability of a Type I Error (α) and a Type II Error (β) are inversely related. Decreasing α makes β larger; increasing α makes β smaller. – Once a decision is made, only one of the two types of errors is possible. If the test rejects H0, for example, only a Type I Error is possible. • The power of a test. – When a particular HA is true, the probability of not making a Type II Error is called power. Power = 1 − β. – The power of a test is the probability of detecting an effect of a particular size when it is present. – Increasing the significance level decreases the probability of a Type II Error and increases power. α ↑, β ↓, power ↑. – For a fixed α, increasing the sample size n makes it easier to detect an effect and therefore decreases the probability of a Type II Error and increases power. n ↑, β ↓, power ↑. • A small percent of the time (α), a significant result will not be a real result. If many tests are run, a small percent of them will produce significant results due to chance alone.22 • With a very large sample, a significant result may point to a result that is real but not practically significant. That is, the difference detected may be so small as to be unimportant or meaningless. • The inference procedures in this book all require two broad conditions to be met. The first is that some type of random sampling or random assignment must be involved. The second condition focuses on sample size and skew to determine whether the point estimate follows the intended distribution. 22Similarly, if many confidence intervals are constructed, a small percent (100 - C%) of them will fail to capture a true value due to chance alone. A value outside the confidence interval is not an impossible value. 286 CHAPTER 5. FOUNDATIONS FOR INFER
|
ENCE Exercises 5.13 Identify hypotheses, Part I. Write the null and alternative hypotheses in words and then symbols for each of the following situations. (a) A tutoring company would like to understand if most students tend to improve their grades (or not) after they use their services. They sample 200 of the students who used their service in the past year and ask them if their grades have improved or declined from the previous year. (b) Employers at a firm are worried about the effect of March Madness, a basketball championship held each spring in the US, on employee productivity. They estimate that on a regular business day employees spend on average 15 minutes of company time checking personal email, making personal phone calls, etc. They also collect data on how much company time employees spend on such non-business activities during March Madness. They want to determine if these data provide convincing evidence that employee productivity changed during March Madness. 5.14 Identify hypotheses, Part II. Write the null and alternative hypotheses in words and using symbols for each of the following situations. (a) Since 2008, chain restaurants in California have been required to display calorie counts of each menu item. Prior to menus displaying calorie counts, the average calorie intake of diners at a restaurant was 1100 calories. After calorie counts started to be displayed on menus, a nutritionist collected data on the number of calories consumed at this restaurant from a random sample of diners. Do these data provide convincing evidence of a difference in the average calorie intake of a diners at this restaurant? (b) The state of Wisconsin would like to understand the fraction of its adult residents that consumed alcohol in the last year, specifically if the rate is different from the national rate of 70%. To help them answer this question, they conduct a random sample of 852 residents and ask them about their alcohol consumption. 5.15 Online communication. A study suggests that 60% of college student spend 10 or more hours per week communicating with others online. You believe that this is incorrect and decide to collect your own sample for a hypothesis test. You randomly sample 160 students from your dorm and find that 70% spent 10 or more hours a week communicating with others online. A friend of yours, who offers to help you with the hypothesis test, comes up with the following set of hypotheses. Indicate any errors you see. H0 : ˆp
|
< 0.6 HA : ˆp > 0.7 5.16 Married at 25. A study suggests that the 25% of 25 year olds have gotten married. You believe that this is incorrect and decide to collect your own sample for a hypothesis test. From a random sample of 25 year olds in census data with size 776, you find that 24% of them are married. A friend of yours offers to help you with setting up the hypothesis test and comes up with the following hypotheses. Indicate any errors you see. H0 : ˆp = 0.24 HA : ˆp = 0.24 5.3. INTRODUCING HYPOTHESIS TESTING 287 5.17 Unemployment and relationship problems. A USA Today/Gallup poll asked a group of unemployed and underemployed Americans if they have had major problems in their relationships with their spouse or another close family member as a result of not having a job (if unemployed) or not having a full-time job (if underemployed). 27% of the 1,145 unemployed respondents and 25% of the 675 underemployed respondents said they had major problems in relationships as a result of their employment status. (a) What are the hypotheses for evaluating if the proportions of unemployed and underemployed people who had relationship problems were different? (b) The p-value for this hypothesis test is approximately 0.35. Explain what this means in context of the hypothesis test and the data. 5.18 Which is higher? In each part below, there is a value of interest and two scenarios (I and II). For each part, report if the value of interest is larger under scenario I, scenario II, or whether the value is equal under the scenarios. (a) The standard error of ˆp when (I) n = 125 or (II) n = 500. (b) The margin of error of a confidence interval when the confidence level is (I) 90% or (II) 80%. (c) The p-value for a Z-statistic of 2.5 calculated based on a (I) sample with n = 500 or based on a (II) sample with n = 1000. (d) The probability of making a Type 2 Error when the alternative hypothesis is true and the signific
|
ance level is (I) 0.05 or (II) 0.10. 5.19 Testing for Fibromyalgia. A patient named Diana was diagnosed with Fibromyalgia, a long-term syndrome of body pain, and was prescribed anti-depressants. Being the skeptic that she is, Diana didn’t initially believe that anti-depressants would help her symptoms. However after a couple months of being on the medication she decides that the anti-depressants are working, because she feels like her symptoms are in fact getting better. (a) Write the hypotheses in words for Diana’s skeptical position when she started taking the anti-depressants. (b) What is a Type 1 Error in this context? (c) What is a Type 2 Error in this context? 288 CHAPTER 5. FOUNDATIONS FOR INFERENCE Chapter highlights Statistical inference is the practice of making decisions from data in the context of uncertainty. In this chapter, we introduced two frameworks for inference: confidence intervals and hypothesis tests. • Confidence intervals are used for estimating unknown population parameters by providing an interval of reasonable values for the unknown parameter with a certain level of confidence. • Hypothesis tests are used to assess how reasonable a particular value is for an unknown pop- ulation parameter by providing degrees of evidence against that value. • The results of confidence intervals and hypothesis tests are, generally speaking, consistent.23 That is: – Values that fall inside a 95% confidence interval (implying they are reasonable) will not be rejected by a test at the 5% significance level (implying they are reasonable), and vice-versa. – Values that fall outside a 95% confidence interval (implying they are not reasonable) will be rejected by a test at the 5% significance level (implying they are not reasonable), and vice-versa. – When the confidence level and the significance level add up to 100%, the conclusions of the two procedures are consistent. • Many values fall inside of a confidence interval and will not be rejected by a hypothesis test. “Not rejecting H0” is NOT equivalent to accepting H0. When we “do not reject H0
|
”, we are asserting that the null value is reasonable, not that the parameter is exactly equal to the null value. • For a 95% confidence interval, 95% is not the probability that the true value lies inside the confidence interval (it either does or it doesn’t). Likewise, for a hypothesis test, α is not the probability that H0 is true (it either is or it isn’t). In both frameworks, the probability is about what would happen in a random sample, not about what is true of the population. • The confidence interval procedures and hypothesis tests described in this book should not be applied unless particular conditions (described in more detail in the following chapters) are met. If these procedures are applied when the conditions are not met, the results may be unreliable and misleading. While a given data set may not always lead us to a correct conclusion, statistical inference gives us tools to control and evaluate how often errors occur. 23In the context of proportions there will be a small range of cases where this is not true. This is because when working with proportions, the SE used for confidence intervals and the SE used for tests are slightly different, as we will see in the next chapter. 5.3. INTRODUCING HYPOTHESIS TESTING 289 Chapter exercises 5.20 Twitter users and news, Part II. A poll conducted in 2013 found that 52% of U.S. adult Twitter users get at least some news on Twitter, and the standard error for this estimate was 2.4%. Identify each of the following statements as true or false. Provide an explanation to justify each of your answers. (a) The data provide statistically significant evidence that more than half of U.S. adult Twitter users get some news through Twitter. Use a significance level of α = 0.01. (b) Since the standard error is 2.4%, we can conclude that 97.6% of all U.S. adult Twitter users were included in the study. (c) If we want to reduce the standard error of the estimate, we should collect less data. (d) If we construct a 90% confidence interval for the percentage of U.S. adults Twitter users who get some news through Twitter, this confidence interval will be wider than
|
a corresponding 99% confidence interval. 5.21 Chronic illness, Part II. In 2013, the Pew Research Foundation reported that “45% of U.S. adults report that they live with one or more chronic conditions”, and the standard error for this estimate is 1.2%. Identify each of the following statements as true or false. Provide an explanation to justify each of your answers. (a) We can say with certainty that the confidence interval from Exercise 5.7 contains the true percentage of U.S. adults who suffer from a chronic illness. (b) If we repeated this study 1,000 times and constructed a 95% confidence interval for each study, then approximately 950 of those confidence intervals would contain the true fraction of U.S. adults who suffer from chronic illnesses. (c) The poll provides statistically significant evidence (at the α = 0.05 level) that the percentage of U.S. adults who suffer from chronic illnesses is below 50%. (d) Since the standard error is 1.2%, only 1.2% of people in the study communicated uncertainty about their answer. 5.22 Relaxing after work. The General Social Survey asked the question: “After an average work day, about how many hours do you have to relax or pursue activities that you enjoy?” to a random sample of 1,155 Americans.24 A 95% confidence interval for the mean number of hours spent relaxing or pursuing activities they enjoy was (1.38, 1.92). (a) Interpret this interval in context of the data. (b) Suppose another set of researchers reported a confidence interval with a larger margin of error based on the same sample of 1,155 Americans. How does their confidence level compare to the confidence level of the interval stated above? (c) Suppose next year a new survey asking the same question is conducted, and this time the sample size is 2,500. Assuming that the population characteristics, with respect to how much time people spend relaxing after work, have not changed much within a year. How will the margin of error of the 95% confidence interval constructed based on data from the new survey compare to the margin of error of the interval
|
stated above? 24National Opinion Research Center, General Social Survey, 2018. 290 CHAPTER 5. FOUNDATIONS FOR INFERENCE 5.23 Testing for food safety. A food safety inspector is called upon to investigate a restaurant with a few customer reports of poor sanitation practices. The food safety inspector uses a hypothesis testing framework to evaluate whether regulations are not being met. If he decides the restaurant is in gross violation, its license to serve food will be revoked. (a) Write the hypotheses in words. (b) What is a Type 1 Error in this context? (c) What is a Type 2 Error in this context? (d) Which error is more problematic for the restaurant owner? Why? (e) Which error is more problematic for the diners? Why? (f) As a diner, would you prefer that the food safety inspector requires strong evidence or very strong evidence of health concerns before revoking a restaurant’s license? Explain your reasoning. 5.24 True or false. Determine if the following statements are true or false, and explain your reasoning. If false, state how it could be corrected. (a) If a given value (for example, the null hypothesized value of a parameter) is within a 95% confidence interval, it will also be within a 99% confidence interval. (b) Decreasing the significance level (α) will increase the probability of making a Type 1 Error. (c) Suppose the null hypothesis is p = 0.5 and we fail to reject H0. Under this scenario, the true population proportion is 0.5. (d) With large sample sizes, even small differences between the null value and the observed point estimate, a difference often called the effect size, will be identified as statistically significant. 5.25 Practical vs. statistical significance. Determine whether the following statement is true or false, and explain your reasoning: “With large sample sizes, even small differences between the null value and the observed point estimate can be statistically significant.” 5.26 Same observation, different sample size. Suppose you conduct a hypothesis test based on a sample where the sample size is n = 50, and arrive at a p-value of 0.08. You then refer
|
back to your notes and discover that you made a careless mistake, the sample size should have been n = 500. Will your p-value increase, decrease, or stay the same? Explain. 291 Chapter 6 Inference for categorical data 6.1 Inference for a single proportion 6.2 Inference for the difference of two proportions 6.3 Testing for goodness of fit using chi-square 6.4 Homogeneity and independence in two-way tables 292 In this chapter, we apply the methods and ideas from Chapter 5 in several contexts for categorical data. We’ll start by revisiting what we learned for a single proportion, where a normal distribution can be used to model the uncertainty in the sample proportion. Next, we apply these same ideas to analyze the difference of two proportions using a normal model. Later in the chapter we will encounter contingency tables, and we will use a different distribution, though the core ideas of hypothesis testing remain the same. For videos, slides, and other resources, please visit www.openintro.org/ahss 6.1. INFERENCE FOR A SINGLE PROPORTION 293 6.1 Inference for a single proportion In this section, we will apply the inferential procedures introduced in Chapter 5 to the context of a single proportion, and we will explore how to do sample size calculations for data collection purposes. We will answer questions such as the following: • Do greater than half of adults in the U.S. oppose nuclear energy? • What percent of adults in the U.S. approve of the way the Supreme Court is handling its job? • What is the standard error is associated with this estimate? • How do we construct a confidence interval for this value? • What sample size is required to estimate this within a 3% margin of error using a 95% confi- dence level? Learning objectives 1. State and verify whether or not the conditions for inference on a proportion using a normal distribution are met. 2. Recognize that the success-failure condition and the standard error calculation are different for the test and for the confidence interval and explain why this is the case. 3. Carry out a complete hypothesis test and confidence interval procedure for a single proportion. 4. Find the minimum sample size needed to estimate a proportion with C% confidence and a margin of
|
error no greater than a certain value. 5. Recognize that margin of error calculations only measure sampling error, and that other types of errors may be present. 294 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.1.1 Distribution of a sample proportion (review) The distribution of a sample proportion, such as the distribution of all possible values for the proportion of people who share a particular opinion in a poll, was introduced in Section 4.1. When the sampling distribution for a sample proportion, ˆp, is approximately normal, we can use confidence intervals and hypothesis tests based on a normal distribution. We call these Z-intervals and Z-tests for short. Here, we review the conditions necessary for a sample proportion to be modeled using a normal distribution. CONDITIONS FOR THE SAMPLING DISTRIBUTION FOR ˆPˆPˆP BEING NEARLY NORMAL The sampling distribution for a sample proportion, ˆp, based on a random sample of size n from a population with a true proportion p, is nearly normal when 1. the sample observations are independent and 2. np ≥ 10 and n(1 − p) ≥ 10. This is called the success-failure condition. If these conditions are met, then the sampling distribution for ˆp is nearly normal with mean µ ˆp = p and standard deviation σ ˆp = p(1−p). n 6.1.2 Checking conditions for inference using a normal distribution We can use a normal model for inference for a proportion when the sampling distribution for the sample proportion is nearly normal. We check that this assumption is reasonable by assessing the independence assumption and verifying that the success-failure condition is met. Independence. Observations can be considered independent when the data are collected from a random process, such as tossing a coin, or from a random sample. Without a random sample or process, the standard error formula would not apply, and it is unclear to what population the inference would apply. When sampling without replacement from a finite population, the observations can be considered independent when sampling less than 10% of the population.1 Success-failure condition. We saw in Section 4.1 that, when that the observations are independent, the sampling distribution for a sample proportion will be nearly normal if the successfailure condition is met, i.e. when the expected number of successes and failures are
|
both at least 10. 1When sampling without replacement and sampling greater than 10% of the population, a modified standard error formula should be used. 6.1. INFERENCE FOR A SINGLE PROPORTION 295 6.1.3 Confidence intervals for a proportion The Gallup organization began measuring the public’s view of the Supreme Court’s job performance in 2000, and has measured it every year since then with the question: “Do you approve or disapprove of the way the Supreme Court is handling its job?”. In 2018, the Gallup poll randomly sampled 1,033 adults in the U.S. and found that 53% of them approved. We know that 53% is just a point estimate. What range of values are reasonable estimates for the percent of the population that approved of the job the Supreme Court is doing? We can use the confidence interval procedure introduced in the previous chapter to answer this question, but first we must clearly identify the parameter we’re trying to estimate and be sure that a Z-interval will be appropriate. The following examples walk through the various steps for carrying out a confidence interval procedure using the Gallup poll data. EXAMPLE 6.1 Identify the population of interest and the parameter of interest for the Gallup poll about the U.S. Supreme Court. Gallup sampled from U.S. adults, therefore the population of interest, and the population to which we can make an inference, is U.S. adults. We know the percent of the sample that said they approve of the job the Supreme Court is doing. However, we do not know what percent of the population would approve. The parameter of interest, which is unknown, is the percent of all U.S. adults that approve of the job the Supreme Court is doing. This is the quantity that we seek to estimate with the confidence interval. EXAMPLE 6.2 Can the sample proportion ˆp be modeled using a normal distribution? In order to construct a Z-interval, the sample statistic must be able to be modeled using a normal distribution. Gallup took a random sample of adults in the U.S. The sample is random and the sample size is much less than 10% of the population size, so the first condition (the independence condition) is satisfied. We must also
|
test the second condition (the success-failure condition) to ensure that the sample size is large enough for the central limit theorem to apply. The successfailure condition is met when np and n(1 − p) are at least 10. Since p is always unknown when constructing a confidence interval for p, we use the sample proportion ˆp to check this condition. Here we have: nˆp = 1033(0.53) = 547 (“successes”) n(1 − ˆp) = 1033(1 − 0.53) = 486 (“failures”) The second condition is satisfied since 547 and 486 are both at least 10. With the two conditions satisfied, we can model the sample proportion ˆp using a normal model and we can construct a Z-interval. 296 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA EXAMPLE 6.3 Calculate the point estimate and the SE of the estimate. The point estimate for the unknown parameter p (the proportion of all U.S. adults) who approve of the job the Supreme Court is doing) is the sample proportion. The point estimate here is ˆp = 0.53. Because the point estimate is the sample proportion, the SE of the estimate is the SE of ˆp. In Section 4.1, we learned that the formula for the standard deviation of ˆp is σ ˆp = p(1 − p) n The proportion p is unknown, so we use the sample proportion ˆp to find the SE of ˆp. SE = ˆp(1 − ˆp) n Here ˆp = 0.53 and n = 1, 033, so the SE of the sample proportion is: SE = 0.53(1 − 0.53) 1033 = 0.016 EXAMPLE 6.4 Construct a 90% confidence interval for p, the proportion of all U.S. adults that approve of the job the Supreme Court is doing. Recall that the general form of a confidence interval is: point estimate ± critical value × SE of estimate We have already found the point estimate and the SE of the estimate. Because we previously verifi
|
ed that ˆp can be modeled using a normal distribution, the critical value is a z. The z value can be found in the t-table on page 514, using the bottom row (∞), where the column corresponds to the confidence level. Here the confidence level is 90%, so z=1.65. We can now construct the 90% confidence interval as follows. point estimate ± z × SE of estimate 0.53 ± 1.65 × 0.016 = (0.504, 0.556) We are 90% confident that the true proportion of U.S. adults who approve of the job the Supreme Court is doing is between 0.504 and.556. EXAMPLE 6.5 Based on the interval, is there evidence that more than half of U.S. adults approve of the job the Supreme Court is doing? The 90% confidence interval (0.504, 0.556) provides an interval of reasonable values for the parameter. The value 0.50 is not in the interval, therefore can be considered unreasonable. Because the entire interval is above 0.50, we do have evidence, at the 90% confidence level, that more than half of U.S. adults (at the time of this poll) approve of the job the Supreme Court is doing. 6.1. INFERENCE FOR A SINGLE PROPORTION 297 EXAMPLE 6.6 Do we have evidence at the 95% confidence level that more than half of U.S. adults approve of the job the Supreme Court is doing? First, we observe that a 95% confidence interval will be wider than a 90% confidence interval. For a 95% Z-interval, z = 1.96. The 95% confidence interval is: 0.53 ± 1.96 × 0.016 = (0.499, 0.561) Now, we see that 0.50 is just barely inside the interval, making it within the range of reasonable values. Therefore, we do not have evidence, at the 95% confidence level, that more than half of U.S. adults (at the time of this poll) approve of the job the Supreme Court is doing. Notice that we come to
|
a different conclusion based on different confidence levels, which may feel a little jarring. However, this will happen with real data, and it highlights why it is important to be explicit in identifying the confidence level being used. Having worked through this example, we now summarize the steps for constructing a confidence interval for a proportion using the five step framework introduce in Chapter 5. CONSTRUCTING A CONFIDENCE INTERVAL FOR A PROPORTION To carry out a complete confidence interval procedure to estimate a single proportion p, Identify: Identify the parameter and the confidence level, C%. The parameter will be a population proportion, e.g. the proportion of all U.S. adults that approve of the job the Supreme Court is doing. Choose: Choose the correct interval procedure and identify it by name. To estimate a single proportion we use a 1-proportion Z-interval. Check: Check conditions for the sampling distribution for ˆp to be nearly normal. 1. Independence: Data come from a random sample or random process. When sampling without replacement, check that sample size is less than 10% of the population size. 2. Success-failure: nˆp ≥ 10 and n(1 − ˆp) ≥ 10. Calculate: Calculate the confidence interval and record it in interval form. point estimate ± z × SE of estimate point estimate: the sample proportion ˆp ˆp(1− ˆp) SE of estimate: n z: use a t-table at row ∞ and confidence level C% (, ) Conclude: Interpret the interval and, if applicable, draw a conclusion in context. We are C% confident that the true proportion of [...] is between. If applicable, draw a conclusion based on whether the interval is entirely above, is entirely below, or contains the value of interest. and 298 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA EXAMPLE 6.7 A February 2018 Marist Poll reports: “Many Americans (68%) think there is intelligent life on other planets.” The results were based on a random sample of 1,033 adults in the U.S. Does this poll provide evidence at the 95% con�
|
��dence level that greater than half of all U.S. adults think there is intelligent life on other planets? Carry out a confidence interval procedure to answer this question. Use the five step framework to organize your work. Identify: First we identify the parameter of interest. Here the parameter is the true proportion of U.S. adults that think there is intelligent life on other planets. We will estimate this at the 95% confidence level. Choose: Because the parameter to be estimated is a single proportion, we will use a 1-proportion Z-interval. Check: We must check that a Z-interval is appropriate. The problem states that the data come from a random sample, and since the population is adults in the U.S., the population size is much more than 10 times larger than the sample size. Next we must check the success-failure condition. Here, we have that 1033(.68) ≥ 10 and 1033(1 − 0.68) ≥ 10. The nearly normal sampling distribution conditions are met, so we can proceed with a 1-proportion Z-interval. Calculate: We will calculate the interval: point estimate ± z × SE of estimate The point estimate is the sample proportion: ˆp = 0.68 The SE of the sample proportion is: ˆp(1− ˆp) n 0.68(1−0.68) 1033 = = 0.015. z is found using the t-table at row ∞ and confidence level C%. For a 95% confidence level, z = 1.96. The 95% confidence interval is given by: 0.68 ± 1.96 × 0.68(1 − 0.68) 1033 0.68 ± 1.96 × 0.015 = (0.651, 0.709) Conclude: We are 95% confident that the true proportion of U.S. adults that think there is intelligent life on other planets is between 0.651 and 0.709. Because the entire interval is above 0.5 we have evidence that greater than half of all U.S. adults think there is intelligent life on other planets. GUIDED PRACTICE 6.8 True or False: There is a 95% probability that between 65.1
|
% and 70.9% of U.S. adults think that there is intelligent life on other planets.2 2False. The true percent of U.S. adults that think there is intelligent life on other planets either falls in that interval or it doesn’t. A correct interpretation of the confidence level would be that if we were to repeat this process over and over, about 95% of the 95% confidence intervals constructed would contain the true value. 6.1. INFERENCE FOR A SINGLE PROPORTION 299 6.1.4 Technology: the 1-proportion Z-interval A calculator can be helpful for evaluating the final interval in the Calculate step. However, it should not be used as a substitute for understanding. TI-83/84: 1-PROPORTION Z-INTERVAL Use STAT, TESTS, 1-PropZInt. 1. Choose STAT. 2. Right arrow to TESTS. 3. Down arrow and choose A:1-PropZInt. 4. Let x be the number of yeses (must be an integer). 5. Let n be the sample size. 6. Let C-Level be the desired confidence level. 7. Choose Calculate and hit ENTER, which returns the confidence interval the sample proportion the sample size (, ) ^p n CASIO FX-9750GII: 1-PROPORTION Z-INTERVAL 1. Navigate to STAT (MENU button, then hit the 2 button or select STAT). 2. Choose the INTR option (F4 button). 3. Choose the Z option (F1 button). 4. Choose the 1-P option (F3 button). 5. Specify the interval details: • Confidence level of interest for C-Level. • Enter the number of successes, x. • Enter the sample size, n. 6. Hit the EXE button, which returns Left, Right ^p n ends of the confidence interval sample proportion sample size GUIDED PRACTICE 6.9 Using a calculator, evaluate the confidence interval from Example 6.7. Recall that we wanted to find a 95% confidence interval for the proportion of U.S. adults who think there is intelligent life on other planets. The
|
sample percent was 68% and the sample size was 1,033.3 3Navigate to the 1-proportion Z-interval on the calculator. To find x, the number of yes responses in the sample, we multiply the sample proportion by the sample size. Here 0.68 × 1033 = 702.44. We must round this to an integer, so we use x = 702. Also, n =1033 and C-Level = 0.95. The calculator output of (0.651, 0.708) matches our previously computed interval of (0.651, 0.709) with minor rounding difference. 300 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.1.5 Choosing a sample size when estimating a proportion Planning a sample size before collecting data is important. If we collect too little data, the standard error of our point estimate may be so large that the estimate is not very useful. On the other hand, collecting data in some contexts is time-consuming and expensive, so we don’t want to waste resources on collecting more data than we need. When considering the sample size, we want to put an upper bound on the margin of error. Recall that the margin of error is measured as the distance between the point estimate and the lower or upper bound of a confidence interval. MARGIN OF ERROR The margin of error of a confidence interval is given by: critical value × SE of estimate The margin of error for a C% confidence interval tells us that we can be C% confident that our point estimate is within that margin of error of the true value. EXAMPLE 6.10 Suppose we are conducting a university survey to determine whether students support a $200 per year increase in fees to pay for a new football stadium. Find the smallest sample size n so that the margin of error of the point estimate ˆp will be no larger than 0.04 when using a 95% confidence level. Because we are working with proportions, the critical value is a z value. We want the margin of error to be less than or equal to 0.04, so we have: z × p(1 − p) n ≤ 0.04 There are two unknowns in the inequality: p and n. If we have an estimate of p, perhaps from a similar survey, we
|
could use that value. If we have no such estimate, we must use some other value for p. It turns out that the margin of error is largest when p is 0.5, so we typically use this worst case estimate of p = 0.5 if no other estimate is available. 1.96 × 1.962 × 1.962 × 0.5(1 − 0.5) n 0.5(1 − 0.5) n 0.5(1 − 0.5) 0.042 ≤ 0.04 ≤ 0.042 ≤ n 600.25 ≤ n n = 601 The sample size must be an integer and we round up because n must be greater than or equal to 600.25. We need at least 601 participants to ensure the sample proportion is within 0.04 of the true proportion with 95% confidence. No estimate of the true proportion is required in sample size computations for a proportion. However, if we have a reliable estimate of the proportion, we should use it in place of the worst case estimate of 0.5. 6.1. INFERENCE FOR A SINGLE PROPORTION 301 EXAMPLE 6.11 A recent estimate of Congress’ approval rating was 17%. If another poll were taken, what minimum sample size does this estimate suggest should be used to have a margin of error no greater than 0.04 with 95% confidence? We complete the same computations as before, except now we use 0.17 instead of 0.5 for p: 1.96 × 0.17(1 − 0.17) n ≤ 0.04 n ≥ 338.8 n = 339 If the true proportion is 0.17, then 339 is the minimum sample size that will ensure a margin of error no greater than 0.04 with 95% confidence. IDENTIFY A SAMPLE SIZE FOR A PARTICULAR MARGIN OF ERROR When estimating a single proportion, we find the minimum sample size n needed to achieve a margin of error no greater than m with a specified confidence level as follows: z × p(1 − p) n ≤ m where z depends on the confidence level. If no reliable estimate of p exists, use p = 0.5. GUIDED PRACTICE 6.12 All other things being equal, what would
|
we have to do to the sample size in order to halve the margin of error (decrease it by a factor of 2)?4 GUIDED PRACTICE 6.13 A manager is about to oversee the mass production of a new tire model in her factory, and she would like to estimate the proportion of these tires that will be rejected through quality control. The quality control team has previously found that about 6.2% of tires fail inspection. (a) How many tires should the manager examine to estimate the failure rate of the new tire model to within 2% with a 90% confidence level?5 (b) What if the estimate of p is 1.7% rather than 6.2%?6 4To decrease the error, we would need to increase the sample size. We note that n is in the denominator of the SE formula, so we would have to quadruple the sample size in order to decrease the SE by a factor of 2. The margin of error as well as the width of the confidence interval is proportional to 1√ n 5The z corresponding to a 90% confidence level is 1.645. Since we have an estimate for p of 6.2%, we use it. So. 0.062(1−0.062) n we have: 1.645 × ≤ 0.02. Rearranging for n gives: n ≥ 393.4, so she should use n = 394. 6Substituting 0.017 for p gives an n of 114. We can note that in this case n × p = 114 × 0.017 = 1.9 < 10. Since the success-failure condition is not met, the use of z = 1.645 based on a normal model is not appropriate. We would need additional methods than what we’ve covered so far to get a good estimate for the minimum sample size in this scenario. √ 302 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.1.6 Hypothesis testing for a proportion While a confidence interval provides a range of reasonable values for an unknown parameter, a hypothesis test evaluates a specific claim. In a hypothesis test, we set up competing hypotheses and find degrees of evidence against the null hypothesis. EXAMPLE 6.14 Deborah Toohey is running for Congress, and her campaign manager
|
claims she has more than 50% support from the district’s electorate. A newspaper collects a random sample of 500 likely voters in the district and estimates Toohey’s support to be 52%. (a) Identify the null and the alternative hypothesis. What value should we use as the null value, p0? (b) Can we model ˆp using a normal model? Check the conditions. (a) The alternative hypothesis, the one that bears the burden of proof, argues that Toohey has more than 50% support. Therefore, HA will be one-sided and the null value will be p0 = 0.5. So we have H0: p = 0.5 and HA: p > 0.5. Note that the hypotheses are about a population parameter. The hypotheses are never about the sample. (b) First, we observe that the problem states that a random sample was chosen. We assume that the size of the electorate in Toohey’s district is more than 10 times the size of the sample. Next, we check the success-failure condition. Because we assume that p = p0 for the calculations of the hypothesis test, we use the hypothesized value p0 rather than the sample value ˆp when verifying the success-failure condition. np0 ≥ 10 → 500(0.5) ≥ 10 n(1 − p0) ≥ 10 → 500(1 − 0.5) ≥ 10 The conditions for a normal model are met. In Chapter 5, we saw that the general form of the test statistic for a hypothesis test takes the following form: test statistic = point estimate − null value SE of estimate When the conditions for a normal model are met: • We use Z as the test statistic and call the test a Z-test. • The point estimate is the sample proportion ˆp (just like for a confidence interval). • Since we compute the test statistic assuming the null hypothesis (that p = p0) is true, we compute the standard error of the sample proportion using the null value p0. SE = p0(1 − p0) n CONFIDENCE INTERVALS VERSUS HYPOTHESIS TESTS FOR A SINGLE PROPORTION 1-proportion Z-interval Check: nˆp ≥ 10 and n(1 − ˆp) ≥ 10 SE = 1-proportion Z-test Check: np
|
0 ≥ 10 and n(1 − p0) ≥ 10 SE = ˆp(1 − ˆp) n p0(1 − p0) n 6.1. INFERENCE FOR A SINGLE PROPORTION 303 EXAMPLE 6.15 (Continues previous example). Deborah Toohey’s campaign manager claimed she has more than 50% support from the district’s electorate. A newspaper poll finds that 52% of 500 likely voters who were sampled support Toohey. Does this provide convincing evidence for the claim by Toohey’s manager at the 5% significance level? We will use a one-sided test with the following hypotheses: H0: p = 0.5. Toohey’s support is 50%. HA: p > 0.5. Toohey’s manager is correct, and her support is higher than 50%. We will use a significance level of α = 0.05 for the test. We can compute the standard error as SE = p0(1 − p0) n = 0.5(1 − 0.5 ) 500 = 0.022 The test statistic can be computed as: Z = point estimate − null value SE of estimate = 0.52 − 0.50 0.022 = 0.89 Because the alternative hypothesis uses a greater than sign (>), this is an upper-tail test. We find the area under the standard normal curve to the right of Z = 0.89. A figure featuring the p-value is shown in Figure 6.1 as the shaded region. Figure 6.1: Sampling distribution for the sample proportion if the null hypothesis is true for Example 6.15. The p-value for the test is shaded. Using a table or a calculator, we find the p-value is 0.19. This p-value of 0.19 is greater than α = 0.05, so we do not reject H0. That is, we do not have sufficient evidence to support Toohey’s campaign manager’s claims that she has more than 50% support within the district. EXAMPLE 6.16 Based on the result above, do we have evidence that Toohey’s support equals 50%? No. In a hypothesis test we look for degrees of evidence against the null
|
hypothesis. We cannot ever prove the null hypothesis directly. The value 0.5 is reasonable, but many other values are reasonable as well. There are many values that would not get rejected by this test. We now summarize the steps for carrying out a hypothesis test for a proportion using the five step framework introduced in the previous chapter. 00.89 304 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA HYPOTHESIS TESTING FOR A PROPORTION To carry out a complete hypothesis test to test the claim that a single proportion p is equal to a null value p0, Identify: Identify the hypotheses and the significance level, α. H0: p = p0 HA: p = p0; HA: p > p0; or HA: p < p0 Choose: Choose the correct test procedure and identify it by name. To test hypotheses about a single proportion we use a 1-proportion Z-test. Check: Check conditions for the sampling distribution for ˆp to be nearly normal, assuming H0: p = p0 is true. 1. Independence: Data come from a random sample or random process. When sampling without replacement, check that sample size is less than 10% of the population size. 2. Success-failure: np0 ≥ 10 and n(1 − p0) ≥ 10 Calculate: Calculate the Z-statistic and p-value. Z = point estimate − null value SE of estimate point estimate: the sample proportion ˆp SE of estimate: null value: p0 p0(1−p0) n p-value = (based on the Z-statistic and the direction of HA) Conclude: Compare the p-value to α, and draw a conclusion in context. If the p-value is < α, reject H0; there is sufficient evidence that [HA in context]. If the p-value is > α, do not reject H0; there is not sufficient evidence that [HA in context]. 6.1. INFERENCE FOR A SINGLE PROPORTION 305 EXAMPLE 6.17 A Gallup poll conducted in March of 2016 found that 54% of respondents oppose nuclear energy. This was the first time since Gallup first asked the question in 1994 that a majority of respondents said they oppose nuclear energy. The survey was based on
|
telephone interviews from a random sample of 1,019 adults in the United States. Does this poll provide evidence that greater than half of U.S. adults oppose nuclear energy? Carry out an appropriate test at the 0.10 significance level. Use the five step framework to organize your work. Identify: We will test the following hypotheses at the α = 10% significance level. H0: p = 0.5 HA: p > 0.5 Greater than half of all U.S. adults oppose nuclear energy. Note: p > 0.5 is what we want to find evidence for; this bears the burden of proof, so this corresponds to HA. Choose: Because the hypotheses are about a single proportion, we choose the 1-proportion Z-test. Check: We must check the independence and success-failure conditions to show that the sample proportion can be modeled using a normal distribution. The problem states that the data come from a random sample. Again, the population is adults in the U.S., so the sample size is much smaller than 10% of the population size. Also, 1019(0.5) ≥ 10 and 1019(1 − 0.5) ≥ 10. (Remember to use the hypothesized proportion, not the sample proportion, when checking the conditions for this test.) Calculate: We will calculate the Z-statistic and the p-value. Z = point estimate − null value SE of estimate The point estimate is the sample proportion: ˆp = 0.54. The value hypothesized for the parameter in H0 is the null value: p0 = 0.5 The SE of the sample proportion, assuming H0 is true, is: p0(1−p0) n 0.5(1−0.5) 1019 = Z = 0.54 − 0.5 0.5(1−0.5) 1019 = 2.5 Because HA uses a greater than sign (>), meaning that it is an upper-tail test, the p-value is the area to the right of Z = 2.5 under the standard normal curve. This area can be found using a normal table or a calculator. The area or p-value = 0.006. Conclude: The p-value of 0.006 is < 0.10, so we reject H0; there is sufficient evidence that greater than half
|
of U.S. adults oppose nuclear energy (as of March 2016). GUIDED PRACTICE 6.18 In context, interpret the p-value of 0.006 from the previous example.7 7Assuming the normal model is accurate and assuming the null hypothesis is true, i.e. that the true proportion of U.S. adults that oppose nuclear energy really is 0.5, there is a 0.006 probability of getting a test statistic as large or larger than 2.5 (H0 uses a > sign, so the p-value is the area in the right tail). Note: We start by assuming H0 is true, that p really equals 0.5. Then, assuming this, we estimate the probability of getting a sample proportion of 0.54 or larger by finding the area under the standard normal curve to the right of 2.5. This probability is very small, which casts doubt on the null hypothesis and leads us to reject it. 306 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.1.7 Technology: the 1-proportion Z-test A calculator can be useful for evaluating the test statistic and computing the p-value. TI-83/84: 1-PROPORTION Z-TEST Use STAT, TESTS, 1-PropZTest. 1. Choose STAT. 2. Right arrow to TESTS. 3. Down arrow and choose 5:1-PropZTest. 4. Let p0 be the null or hypothesized value of p. 5. Let x be the number of yeses (must be an integer). 6. Let n be the sample size. 7. Choose =, <, or > to correspond to HA. 8. Choose Calculate and hit ENTER, which returns z Z-statistic p-value p the sample proportion ^p the sample size n CASIO FX-9750GII: 1-PROPORTION Z-TEST The steps closely match those of the 1-proportion confidence interval. 1. Navigate to STAT (MENU button, then hit the 2 button or select STAT). 2. Choose the TEST option (F3 button). 3. Choose the Z option (F1 button). 4. Choose the 1-P option (F3 button). 5. Specify the test details: • Specify the sidedness of the test using the F1, F2, and F3 keys.
|
• Enter the null value, p0. • Enter the number of successes, x. • Enter the sample size, n. 6. Hit the EXE button, which returns z Z-statistic p-value p the sample proportion ^p the sample size n GUIDED PRACTICE 6.19 Using a calculator, find the test statistic and p-value for the earlier Example 6.17. Recall that we were looking for evidence that more than half of U.S. adults oppose nuclear energy. The sample percent was 54%, and the sample size was 1019.8 8Navigate to the 1-proportion Z-test on the calculator. Let p0 = 0.5. To find x, do 0.54 × 1019 = 550.26. This needs to be an integer, so round to the closest integer. Here x = 550. Also, n = 1019. We are looking for evidence that greater than half oppose, so choose > p0. When we do Calculate, we get the test statistic: Z = 2.64 and the p-value: p = 0.006. 6.1. INFERENCE FOR A SINGLE PROPORTION 307 Section summary Most of the confidence interval procedures and hypothesis tests of this book involve: a point estimate, the standard error for the point estimate, and an assumption about the shape of the sampling distribution of the point estimate. In this section, we explore inference when the parameter of interest is a proportion. • We use the sample proportion ˆp as the point estimate for the unknown population proportion p. The sampling distribution for ˆp is approximately normal when the success-failure condition is met and the observations are independent. When the sampling distribution for ˆp is normal, the standardized test statistic also follows a normal distribution. • When verifying the success-failure condition and calculating the SE, – use the sample proportion ˆp for the confidence interval, but – use the null/hypothesized proportion p0 for the hypothesis test. • When there is one sample and the parameter of interest is a single proportion: – Estimate p at the C% confidence level using a 1-proportion Z-interval. – Test H0: p = p0 at the α significance level using a 1-proportion Z-test. • The
|
one proportion Z-test and Z-interval require the sampling distribution for ˆp to be nearly normal. For this reason we must check that the following conditions are met. 1. Independence: The data should come from a random sample or random process. When sampling without replacement, check that the sample size is less than 10% of the population size. 2. Success-failure for Interval: nˆp ≥ 10 and n(1 − ˆp) ≥ 10. Success-failure for Test, assuming H0: p = p0 is true: np0 ≥ 10 and n(1 − p0) ≥ 10. • When the conditions are met, we calculate the confidence interval and the test statistic as follows. Confidence interval: point estimate ± z × SE of estimate Test statistic: Z = point estimate − null value SE of estimate Here the point estimate is the sample proportion ˆp. The SE of estimate is the SE of the sample proportion. – For an Interval, use SE = ˆp(1− ˆp) n. – For a Test with H0: p = p0, use SE = p0(1−p0) n. • The margin of error (M E) for a one-sample confidence interval for a proportion is z ˆp(1− ˆp) n, which is proportional to 1√ n. • To find the minimum sample size needed to estimate a proportion with a given confidence level and a given margin of error, m, set up an inequality of the form: z ˆp(1 − ˆp) n < m z depends on the desired confidence level. Unless a particular proportion is given in the problem, use ˆp = 0.5. We solve for the sample size n. The final answer should be an integer, since n refers to a number of people or things. 308 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA Exercises 6.1 Orange tabbies. Suppose that 90% of orange tabby cats are male. Determine if the following statements are true or false, and explain your reasoning. (a) The distribution of sample proportions of random samples of size 30 is left skewed. (b) Using
|
a sample size that is 4 times as large will reduce the standard error of the sample proportion by one-half. (c) The distribution of sample proportions of random samples of size 140 is approximately normal. (d) The distribution of sample proportions of random samples of size 280 is approximately normal. 6.2 Young Americans, Part II. About 25% of young Americans have delayed starting a family due to the continued economic slump. Determine if the following statements are true or false, and explain your reasoning.9 (a) The distribution of sample proportions of young Americans who have delayed starting a family due to the continued economic slump in random samples of size 12 is right skewed. (b) In order for the distribution of sample proportions of young Americans who have delayed starting a family due to the continued economic slump to be approximately normal, we need random samples where the sample size is at least 40. (c) A random sample of 50 young Americans where 20% have delayed starting a family due to the continued economic slump would be considered unusual. (d) A random sample of 150 young Americans where 20% have delayed starting a family due to the continued economic slump would be considered unusual. (e) Tripling the sample size will reduce the standard error of the sample proportion by one-third. 6.3 Gender equality. The General Social Survey asked a random sample of 1,390 Americans the following question: “On the whole, do you think it should or should not be the government’s responsibility to promote equality between men and women?” 82% of the respondents said it “should be”. At a 95% confidence level, this sample has 2% margin of error. Based on this information, determine if the following statements are true or false, and explain your reasoning.10 (a) We are 95% confident that between 80% and 84% of Americans in this sample think it’s the government’s responsibility to promote equality between men and women. (b) We are 95% confident that between 80% and 84% of all Americans think it’s the government’s respon- sibility to promote equality between men and women. (c) If we considered many random samples of 1,390 Americans, and we calculated 95% confidence intervals for each, 95% of these intervals would include the true population proportion of Americans who think it’s the government
|
’s responsibility to promote equality between men and women. (d) In order to decrease the margin of error to 1%, we would need to quadruple (multiply by 4) the sample size. (e) Based on this confidence interval, there is sufficient evidence to conclude that a majority of Americans think it’s the government’s responsibility to promote equality between men and women. 6.4 Elderly drivers. The Marist Poll published a report stating that 66% of adults nationally think licensed drivers should be required to retake their road test once they reach 65 years of age. It was also reported that interviews were conducted on a random sample of 1,018 American adults, and that the margin of error was 3% using a 95% confidence level.11 (a) Verify the margin of error reported by The Marist Poll. (b) Based on a 95% confidence interval, does the poll provide convincing evidence that more than two thirds of the population think that licensed drivers should be required to retake their road test once they turn 65? 9Demos.org. “The State of Young America: The Poll”. In: (2011). 10National Opinion Research Center, General Social Survey, 2018. 11Marist Poll, Road Rules: Re-Testing Drivers at Age 65?, March 4, 2011. 6.1. INFERENCE FOR A SINGLE PROPORTION 309 6.5 Fireworks on July 4th. A local news outlet reported that 56% of 600 randomly sampled Kansas residents planned to set off fireworks on July 4th. Determine the margin of error for the 56% point estimate using a 95% confidence level.12 6.6 Life rating in Greece. Greece has faced a severe economic crisis since the end of 2009. A Gallup poll surveyed 1,000 randomly sampled Greeks in 2011 and found that 25% of them said they would rate their lives poorly enough to be considered “suffering”.13 (a) Describe the population parameter of interest. What is the value of the point estimate of this parameter? (b) Check if the conditions required for constructing a confidence interval based on these data are met. (c) Construct a 95% confidence interval for the proportion of Greeks who are “suff
|
ering”. (d) Without doing any calculations, describe what would happen to the confidence interval if we decided to use a higher confidence level. (e) Without doing any calculations, describe what would happen to the confidence interval if we used a larger sample. 6.7 Study abroad. A survey on 1,509 high school seniors who took the SAT and who completed an optional web survey shows that 55% of high school seniors are fairly certain that they will participate in a study abroad program in college.14 (a) Is this sample a representative sample from the population of all high school seniors in the US? Explain your reasoning. (b) Let’s suppose the conditions for inference are met. Even if your answer to part (a) indicated that this approach would not be reliable, this analysis may still be interesting to carry out (though not report). Construct a 90% confidence interval for the proportion of high school seniors (of those who took the SAT) who are fairly certain they will participate in a study abroad program in college, and interpret this interval in context. (c) What does “90% confidence” mean? (d) Based on this interval, would it be appropriate to claim that the majority of high school seniors are fairly certain that they will participate in a study abroad program in college? 6.8 Legalization of marijuana, Part I. The General Social Survey asked a random sample of 1,578 US residents: “Do you think the use of marijuana should be made legal, or not?” 61% of the respondents said it should be made legal.15 (a) Is 61% a sample statistic or a population parameter? Explain. (b) Construct a 95% confidence interval for the proportion of US residents who think marijuana should be made legal, and interpret it in the context of the data. (c) A critic points out that this 95% confidence interval is only accurate if the statistic follows a normal distribution, or if the normal model is a good approximation. Is this true for these data? Explain. (d) A news piece on this survey’s findings states, “Majority of Americans think marijuana should be legal- ized.” Based on your confidence interval, is this news piece’s statement justi�
|
��ed? 6.9 National Health Plan, Part I. A Kaiser Family Foundation poll for a random sample of US adults in 2019 found that 79% of Democrats, 55% of Independents, and 24% of Republicans supported a generic “National Health Plan”. There were 347 Democrats, 298 Republicans, and 617 Independents surveyed.16 (a) A political pundit on TV claims that a majority of Independents support a National Health Plan. Do these data provide strong evidence to support this type of statement? (b) Would you expect a confidence interval for the proportion of Independents who oppose the public option plan to include 0.5? Explain. 12Survey USA, News Poll #19333, data collected on June 27, 2012. 13Gallup World, More Than One in 10 “Suffering” Worldwide, data collected throughout 2011. 14studentPOLL, College-Bound Students’ Interests in Study Abroad and Other International Learning Activities, January 2008. 15National Opinion Research Center, General Social Survey, 2018. 16Kaiser Family Foundation, The Public On Next Steps For The ACA And Proposals To Expand Coverage, data collected between Jan 9-14, 2019. 310 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.10 Is college worth it? Part I. Among a simple random sample of 331 American adults who do not have a four-year college degree and are not currently enrolled in school, 48% said they decided not to go to college because they could not afford school.17 (a) A newspaper article states that only a minority of the Americans who decide not to go to college do so because they cannot afford it and uses the point estimate from this survey as evidence. Conduct a hypothesis test to determine if these data provide strong evidence supporting this statement. (b) Would you expect a confidence interval for the proportion of American adults who decide not to go to college because they cannot afford it to include 0.5? Explain. Some people claim that they can tell the difference between a diet soda and a regular 6.11 Taste test. soda in the first sip. A researcher wanting to test this claim randomly sampled 80 such people. He then filled 80 plain white cups with soda, half diet and half regular through random assignment, and
|
asked each person to take one sip from their cup and identify the soda as diet or regular. 53 participants correctly identified the soda. (a) Do these data provide strong evidence that these people are able to detect the difference between diet and regular soda, in other words, are the results significantly better than just random guessing? Carry out an appropriate test and include all steps of the Identify, Choose, Check, Calculate, Conclude framework. (b) Interpret the p-value in this context. Is college worth it? Part II. Exercise 6.10 presents a poll where 48% of 331 randomly selected 6.12 Americans reported that they decided not to go to college because they cannot afford it. (a) Calculate a 90% confidence interval to estimate the proportion of Americans who decide to not go to college because they cannot afford it. Include all steps of the Identify, Choose, Check, Calculate, Conclude framework. (b) Suppose we wanted the margin of error for the 90% confidence level to be about 1.5%. How large of a survey would you recommend? 6.13 National Health Plan, Part II. Exercise 6.9 presents the results of a poll evaluating support for a generic “National Health Plan” in the US in 2019, reporting that 55% of Independents are supportive. If we want to estimate the percent of Independents who are supportive this year to within 1% with 90% confidence, what would be an appropriate sample size? 6.14 Legalize Marijuana, Part II. As discussed in Exercise 6.8, the General Social Survey reported a sample where about 61% of US residents thought marijuana should be made legal. If we wanted to limit the margin of error of a 95% confidence interval to 2%, about how many Americans would we need to survey? 17Pew Research Center Publications, Is College Worth It?, data collected between March 15-29, 2011. 6.2. INFERENCE FOR THE DIFFERENCE OF TWO PROPORTIONS 311 6.2 Inference for the difference of two proportions We often wish to compare two groups to each other. In this section, we will answer the following questions: • How much more effective is a blood thinner than a placebo for those who undergo CPR
|
for a heart attack? • How different is the approval of the 2010 healthcare law under two different question phrasings? • Does the use of fish oils reduce heart attacks better than a placebo? Learning objectives 1. State and verify whether or not the conditions for inference on the difference of two proportions using a normal distribution are met. 2. Recognize that the standard error calculation is different for the test and for the interval, and explain why that is the case. 3. Know how to calculate the pooled proportion and when to use it. 4. Carry out a complete confidence interval procedure for the difference of two proportions. 5. Carry out a complete hypothesis test for the difference of two proportions. 6.2.1 Sampling distribution for the difference of two proportions (review) In this section we want to compare proportions from two independent groups. When comparing two proportions, the quantity that we generally want to estimate is the difference p1 − p2, which tells us how far apart the two population proportions are. Before we perform inference for the two proportion case, we must review the sampling distribution for ˆp1 − ˆp2, which will represent our point estimate. We know from Section 4.3 that when the independence condition is satisfied, the sampling distribution for ˆp1 − ˆp2 is centered on p1 − p2 and the standard deviation is given by: σ ˆp1− ˆp2 = p1(1 − p1) n1 + p2(1 − p2) n2. When the individual population proportions are unknown, we estimate the standard deviation of ˆp1 − ˆp2 using the Standard Error, abbreviated SE. The SE of ˆp1 − ˆp2 is found by substituting in our best estimates of p1 and p2 using the sample values: SE ˆp1− ˆp2 = ˆp1(1 − ˆp1) n1 + ˆp2(1 − ˆp2) n2. The difference of two sample proportions ˆp1 − ˆp2 follows a nearly normal distribution when two conditions are met. First,
|
the sampling distribution for each sample proportion must be nearly normal. Second, the observations must be independent, both within and between groups. We cover these conditions in greater detail next. 312 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.2.2 Checking conditions for inference using a normal distribution When comparing two proportions, we carry out inference on p1 − p2. To model the test statistic with a normal distribution, we need the sampling distribution for ˆp1 − ˆp2 to be nearly normal, and this assumption is reasonable when two conditions are met: Independence. The observations across the two samples are independent. This condition is generally satisfied by checking whether the data are collected from two independent random samples or from an experiment with two randomly assigned treatments. Randomly assigning subjects to treatments is equivalent to randomly assigning treatments to subjects. When sampling without replacement, the observations can be considered independent when the sample sizes is less than 10% of the population size for both samples. Success-failure condition. In the two-sample case, the number of successes and failures should be at least 10 for both groups, so there are four inequalities to check. 6.2.3 Confidence interval for the difference of two proportions We consider an experiment for patients who underwent CPR for a heart attack and were subsequently admitted to a hospital. These patients were randomly divided into a treatment group where they received a blood thinner or the control group where they did not receive a blood thinner. The outcome variable of interest was whether the patients survived for at least 24 hours. The results are shown in Figure 6.2. Treatment Control Total Survived Died 14 11 25 26 39 65 Total 40 50 90 Figure 6.2: Results for the CPR study. Patients in the treatment group were given a blood thinner, and patients in the control group were not. Here, the parameter of interest is a difference of population proportions, specifically, the difference in the proportion of similar patients that would survive for at least 24 hours if in the treatment group versus if in the control group. Let: p1 : proportion that would survive in treatment group, and p2 : proportion that would survive in control group Then the parameter of interest is p1 − p2. In order to use a Z-interval to estimate this difference, we must see if the point estimate, ˆp1 − �
|
�p2, follows a normal distribution. Because the patients were randomly assigned to one of the two groups and one heart attack patient is unlikely to influence the next that was in the study, the observations are considered independent, both within the samples and between the samples (since there is no sampling, there is no need to check the 10% condition). Next, the success-failure condition should be verified for each group. We use the sample proportions along with the sample sizes to check the condition. n1 ˆp1 ≥ 10 40 × 14 40 ≥ 10 n1(1 − ˆp1) ≥ 10 14 40 ) ≥ 10 40 × (1 − n2 ˆp2 ≥ 10 50 × 11 50 ≥ 10 n2(1 − ˆp2) ≥ 10 11 50 ) ≥ 10 50 × (1 − Because all conditions are met, the normal model can be used for the point estimate of the difference in survival rate. The point estimate is: ˆp1 − ˆp2 = 14 40 − 11 50 = 0.35 − 0.22 = 0.13 6.2. INFERENCE FOR THE DIFFERENCE OF TWO PROPORTIONS 313 We compute the standard error for the difference of sample proportions in the same way that we compute the standard deviation for the difference of sample proportions – the only difference is that we use the sample proportions in place of the population proportions: SE = ˆp1(1 − ˆp1) n1 + ˆp2(1 − ˆp2) n2 = 0.35(1 − 0.35) 40 + 0.22(1 − 0.22) 50 = 0.095 Let us estimate the true difference in survival rate with 90% confidence. For a 90% confidence level, we use z = 1.645. The 90% confidence interval is calculated as: point estimate ± z × SE of estimate 0.13 ± 1.65 × 0.095 (−0.027, 0.287) We are 90% confident that the true difference in the survival rate (treatment − control) lies between -0.027 and 0.287
|
. That is, we are 90% confident that the treatment of blood thinners changes survival rate for patients like those in the study by -2.7% to +28.7% percentage points. Because this interval contains both negative and positive values, we do not have enough information to say with confidence whether blood thinners harm or help heart attack patients who have been admitted after they have undergone CPR. CONSTRUCTING A CONFIDENCE INTERVAL FOR THE DIFFERENCE OF TWO PROPORTIONS To carry out a complete confidence interval procedure to estimate the difference of two proportions p1 − p2, Identify: Identify the parameter and the confidence level, C%. The parameter will be a difference of proportions, e.g. the true difference in the proportion of 17 and 18 year olds with a summer job (proportion of 18 year olds − proportion of 17 year olds). Choose: Identify the correct interval procedure and identify it by name. To estimate a difference of proportions we choose the 2-proportion Z-interval. Check: Check conditions for the sampling distribution for ˆp1 − ˆp2 to be nearly normal. 1. Independence: Data come from 2 independent random samples or from a randomized experiment with two treatments. When sampling without replacement, check that the sample size is less than 10% of the population size for both samples. 2. Success-failure: n1 ˆp1 ≥ 10, n1(1 − ˆp1) ≥ 10, n2 ˆp2 ≥ 10, and n2(1 − ˆp2) ≥ 10 Calculate: Calculate the confidence interval and record it in interval form. point estimate ± z × SE of estimate point estimate: the difference of sample proportions ˆp1 − ˆp2 SE of estimate: ˆp1(1− ˆp1) n1 + ˆp2(1− ˆp2) n2 z: use a t-table at row ∞ and confidence level C% (, ) Conclude: Interpret the interval and, if applicable, draw a conclusion in context. We are C% confident
|
that the true difference in the proportion of [...] is between and. If applicable, draw a conclusion based on whether the interval is entirely above, is entirely below, or contains the value 0. 314 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA EXAMPLE 6.20 A remote control car company is considering a new manufacturer for wheel gears. The new manufacturer would be more expensive but their higher quality gears are more reliable, resulting in happier customers and fewer warranty claims. However, management must be convinced that the more expensive gears are worth the conversion before they approve the switch. The quality control engineer collects a sample of gears from each supplier, examining 1000 gears from each company, and finds that 879 gears pass inspection from the current supplier and 958 pass inspection from the prospective supplier. Using these data, construct a 95% confidence interval for the difference in the proportion from each supplier that would pass inspection. Use the five step framework described above to organize your work. Identify: First we identify the parameter of interest. Here the parameter we wish to estimate is the true difference in the proportion of gears from each supplier that would pass inspection, p1 − p2. We will take the difference as: current − prospective, so p1 is the true proportion that would pass from the current supplier and p2 is the true proportion that would pass from the prospective supplier. We will estimate the difference using a 95% confidence level. Choose: Because the parameter to be estimated is a difference of proportions, we will use a 2- proportion Z-interval. Check: The samples are independent, but not necessarily random, so to proceed we must assume the gears are all independent. For this sample we will suppose this assumption is reasonable, but the engineer would be more knowledgeable as to whether this assumption is appropriate. We will also assume that the 1000 gears represents less than 10% of the total gears from each supplier. Next, we verify the minimum sample size conditions: 1000 × 879 1000 ≥ 10 1000 × 121 1000 ≥ 10 1000 × 958 1000 ≥ 10 1000 × 42 1000 ≥ 10 The success-failure condition is met for both samples. Calculate: We will calculate the interval: point estimate ± z × SE of estimate The point estimate is the difference of sample proportions: �
|
�p1 − ˆp2 = 0.879 − 0.958 = −0.079. The SE of the difference of sample proportions is: ˆp1(1− ˆp1) 0.879(1−0.879) 1000 = + ˆp2(1− ˆp2) n2 + 0.958(1−0.958) 1000 n1 = 0.0121 So the 95% confidence interval is given by: 0.879 − 0.958 ± 1.96 × 0.879(1 − 0.879) 1000 + 0.958(1 − 0.958) 1000 −0.079 ± 1.96 × 0.0121 (−0.103, −0.055) Conclude: We are 95% confident that the true difference (current − prospective) in the proportion that would pass inspection is between -0.103 and -0.055, meaning that we are 95% confident that the prospective supplier would have between a 5.5% and 10.3% greater rate of passing inspection. Because the entire interval is below zero, the data provide sufficient evidence that the prospective gears pass inspection more often than the current gears. The remote control car company should go with the new manufacturer. 6.2. INFERENCE FOR THE DIFFERENCE OF TWO PROPORTIONS 315 6.2.4 Technology: the 2-proportion Z-interval As with the 1-proportion Z-interval, a calculator can be helpful for evaluating the final interval. TI-83/84: 2-PROPORTION Z-INTERVAL Use STAT, TESTS, 2-PropZInt. 1. Choose STAT. 2. Right arrow to TESTS. 3. Down arrow and choose B:2-PropZInt. 4. Let x1 be the number of yeses (must be an integer) in sample 1 and let n1 be the size of sample 1. 5. Let x2 be the number of yeses (must be an integer) in sample 2 and let n2 be the size of sample 2. 6. Let C-Level be the desired confidence level. 7. Choose Calcul
|
ate and hit ENTER, which returns: the confidence interval sample 1 proportion sample 2 proportion (, ) ^p1 ^p2 n1 n2 size of sample 1 size of sample 2 CASIO FX-9750GII: 2-PROPORTION Z-INTERVAL 1. Navigate to STAT (MENU button, then hit the 2 button or select STAT). 2. Choose the INTR option (F4 button). 3. Choose the Z option (F1 button). 4. Choose the 2-P option (F4 button). 5. Specify the interval details: • Confidence level of interest for C-Level. • Enter the number of successes for each group, x1 and x2. • Enter the sample size for each group, n1 and n2. 6. Hit the EXE button, which returns Left, Right ^p1, ^p2 n1, n2 the ends of the confidence interval the sample proportions sample sizes GUIDED PRACTICE 6.21 From Example 6.20, we have that a quality control engineer collects a sample of gears, examining 1000 gears from each company and finds that 879 gears pass inspection from the current supplier and 958 pass inspection from the prospective supplier. Use a calculator to find a 95% confidence interval for the difference (current − prospective) in the proportion that would pass inspection.18 18Navigate to the 2-proportion Z-interval on the calculator. Let x1 = 879, n1 = 1000, x2 = 958, and n2 = 1000. C-Level is.95. This should lead to an interval of (-0.1027, -0.0553), which matches what we found previously. 316 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA H0: p1 = p2 H0: p1 = p2 6.2.5 Hypothesis testing when H0: p1 = p2 Here we use a new example to examine a special estimate of the standard error when the null hypothesis is that two population proportions equal each other, i.e. H0: p1 = p2. We investigate whether the way a question is phrased can influence a person’s response. Pew Research Center conducted a survey with the following question: As
|
you may know, by 2014 nearly all Americans will be required to have health insurance. [People who do not buy insurance will pay a penalty] while [People who cannot afford it will receive financial help from the government]. Do you approve or disapprove of this policy? For each randomly sampled respondent, the statements in brackets were randomized: either they were kept in the original order given above, or they were reversed. Results are presented in Figure 6.3 sample size Approve law (%) 47 771 Disapprove law (%) 49 732 34 63 Other 3 3 “People who do not buy insurance will pay a penalty” is given first (original order) “People who cannot afford it will receive financial help from the government” is given first (reversed order) Figure 6.3: Results for a Pew Research Center poll where the ordering of two statements in a question regarding healthcare were randomized. GUIDED PRACTICE 6.22 Is this study an experiment or an observational study?19 The approval percents of 47% and 34% seem far apart. However, could this difference be due to random chance? We will answer this question using a hypothesis test. To simplify things, let p1: the proportion of respondents that would approve of policy with the original statement ordering, and p2: the proportion of respondents that would approve of policy with the reversed statement ordering. EXAMPLE 6.23 Set up hypotheses to test whether the two statement orders produce the same response. The null claim is that the question order does not matter, that is, that the two proportions should be equal. The alternate claim, the one that bears the burden of proof, is that the question ordering does matter. H0: p1 = p2 HA: p1 = p2 19There is a random sample involved, but there are also two treatments. Half of the respondents are given the original statement order and the other half, randomly, are given the reversed statement order. This is an experiment because there are randomly assigned treatments. 6.2. INFERENCE FOR THE DIFFERENCE OF TWO PROPORTIONS 317 Now, we can note that: p1 = p2 is equivalent to p1 − p2 = 0, and p1 = p2 is equivalent to p1 − p2 = 0. We can now see that the hypotheses are really about a
|
difference of proportions: p1 − p2. In the last section, we used a 2-proportion Z-interval to estimate the parameter p1 − p2; here, we will use a 2-proportion Z-test to test the null hypothesis that p1 − p2 = 0, i.e. that p1 = p2. Recall that the test statistic Z has the form: Z = point estimate − null value SE of estimate The parameter of interest is p1 − p2, so the point estimate will be the observed difference of sample proportions: ˆp1 − ˆp2 = 0.47 − 0.34 = 0.13. The null value depends on the null hypothesis. The null hypothesis is that the approval rate would be the same for both statement orderings, i.e. that the difference is 0, therefore, the null value is 0. In this section we consider only the case where H0: p1 = p2, so the null value for the difference will always be 0. The SD of a difference of sample proportions has the form: SD = p1(1 − p1) n1 + p2(1 − p2) n2 However, in a hypothesis test, the distribution of the point estimate is always examined assuming the null hypothesis is true, i.e. in this case, p1 = p2. Both the success-failure check and the standard error formula should reflect this equality in the null hypothesis. We will use pc to represent the common proportion that support healthcare law regardless of statement order: SD = pc(1 − pc) n1 + pc(1 − pc) n2 = pc(1 − pc) 1 n1 + 1 n2 We don’t know the true proportion pc, but we can obtain a good estimate of it, ˆpc, by pooling the results of both samples. We find the total number of “yeses” or “successes” and divide that by the total number of cases. This is equivalent to taking a weighted average of ˆp1 and ˆp2. We call ˆpc the pooled sample proportion, and we use it to check the success-failure condition and to compute the standard error when the null hypothesis is that p1 =
|
p2. Here: ˆpc = 771(0.47) + 732(0.34) 771 + 732 = 0.407 POOLED SAMPLE PROPORTION When the null hypothesis is p1 = p2, it is useful to find the pooled sample proportion: ˆpc = number of “successes” number of cases = x1 + x2 n1 + n2 = n1 ˆp1 + n2 ˆp2 n1 + n2 Here x1 represents the number of successes in sample 1. If x1 is not given, it can be computed as n1 × ˆp1. Similarly, x2 represents the number of successes in sample 2 and can be computed as n2 × ˆp2. 318 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA H0: p1 = p2 USE THE POOLED SAMPLE PROPORTION WHEN H0: p1 = p2 H0: p1 = p2 When the null hypothesis states that the proportions are equal, we use the pooled sample proportion (ˆpc) to check the success-failure condition and to estimate the standard error: SE = ˆpc(1 − ˆpc) 1 n1 + 1 n2 EXAMPLE 6.24 Verify that conditions for using the normal are met and find the SE of estimate for this hypothesis test. Recall that the pooled proportion ˆpc = 0.407, n1 = 771, and n2 = 732. The data do come from a randomized experiment, where the treatments are the two different orderings of the question regarding healthcare (because this is an experiment, the 10% condition does not need to be checked). Also, the success-failure condition (minimums of 10) easily holds for each group. 771 × 0.407 ≥ 10 771 × (1 − 0.407) ≥ 10 732 × 0.407 ≥ 10 732 × (1 − 0.407) ≥ 10xf Here, we compute the SE for the difference of sample proportions as: SE = ˆpc(1 − ˆpc) 1 n1 + 1 n2 = 0.407(1 − 0.407) 1 771 + 1 732 = 0.025 EXAMPLE
|
6.25 Complete the hypothesis test using a significance level of 0.01. We have already set up the hypotheses and verified that the difference of proportions can be modeled using a normal distribution. We can now calculate the test statistic and p-value. Z = point estimate − null value SE of estimate = (0.47 − 0.34) − 0 0.025 = 5.2 This is a two-tailed test as HA is that p1 = p2. We can find the area in one tail and double it. Here, the p-value ≈ 0. Because the p-value is smaller than α = 0.01, we reject the null hypothesis and conclude that the order of the statements affects how likely a respondent is to support the 2010 healthcare law. 6.2. INFERENCE FOR THE DIFFERENCE OF TWO PROPORTIONS 319 HYPOTHESIS TESTING FOR THE DIFFERENCE OF TWO PROPORTIONS To carry out a complete hypothesis test to test the claim that two proportions p1 and p2 are equal to each other, Identify: Identify the hypotheses and the significance level, α. H0: p1 = p2 HA: p1 = p2; HA: p1 > p2; or HA: p1 < p2 Choose: Choose the correct test procedure and identify it by name. To test hypotheses about a difference of proportions we use a 2-proportion Z-test. Check: Check conditions for the sampling distribution for ˆp1− ˆp2 to be nearly normal, assuming H0: p1 = p2 is true. 1. Independence: Data come from 2 independent random samples or from a randomized experiment with two treatments. When sampling without replacement, check that the sample size is less than 10% of the population size for both samples. 2. Success-failure: n1 ˆpc ≥ 10, n1(1 − ˆpc) ≥ 10, n2 ˆpc ≥ 10, and n2(1 − ˆpc) ≥ 10 Calculate: Calculate the Z-statistic and p-value. Z = point estimate − null value SE of estimate point estimate: the difference of sample proportions ˆp1 − ˆp
|
2 1 SE of estimate: ˆpc(1 − ˆpc) n1 null value: 0 + 1 n2, where ˆpc is the pooled proportion p-value = (based on the Z-statistic and the direction of HA) Conclude: Compare the p-value to α, and draw a conclusion in context. If the p-value is < α, reject H0; there is sufficient evidence that [HA in context]. If the p-value is > α, do not reject H0; there is not sufficient evidence that [HA in context]. 320 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA EXAMPLE 6.26 A 5-year experiment was conducted to evaluate the effectiveness of fish oils on reducing heart attacks, where each subject was randomized into one of two treatment groups. We’ll consider heart attack outcomes in these patients: fish oil placebo heart attack 145 200 no event Total 12933 12938 12788 12738 Carry out a complete hypothesis test at the 10% significance level to test whether the use of fish oils is effective in reducing heart attacks. Identify: Define p1 and p2 as follows: p1: the true proportion that would suffer a heart attack if given fish oil p2: the true proportion that would suffer a heart attack if given placebo We will test the following hypotheses at the α = 0.10 significance level. H0: p1 = p2 HA: p1 < p2 Fish oil and placebo are equally effective. Fish oil is effective in reducing heart attacks. Choose: Because we are testing whether two proportions equal each other, we choose the 2- proportion Z-test for a difference of proportions. Check: We must verify that the difference of sample proportions can be modeled using a normal distribution. First we note that there is a randomized experiment with two treatments: fish oil and placebo. Second, we calculate the pooled proportion as follows: ˆpc = x1 + x2 n1 + n2 = 145 + 200 12933 + 12938 = 0.0133 We can now verify: 12933(0.0133
|
) ≥ 10, 12933(1 − 0.0133) ≥ 10, 12938(0.0133) ≥ 10, and 12938(1 − 0.0133) ≥ 10, so both conditions are met. Calculate: We will calculate the Z-statistic and the p-value. Z = point estimate − null value SE of estimate The point estimate is the difference of sample proportions: ˆp1− ˆp2 = 0.0112−0.0155 = −0.0043. The value hypothesized for the parameter in H0 is the null value: null value = 0. The pooled proportion, calculated above, is: ˆpc = 0.0133. The SE of the difference of sample proportions, assuming H0 is true, is: ˆpc(1 − ˆpc) = 0.0133(1 − 0.0133) 12938 = 0.00142. 12933 + 1 1 1 n1 + 1 n2 Z = −0.0043 − 0 0.00142 = −3.0 Because HA uses a less than, meaning that it is a lower-tail test, the p-value is the area to the left of Z = −3.0 under the standard normal curve. This area can be found using a normal table or a calculator. The area or p-value = 0.0013. Conclude: The p-value of 0.0013 is < 0.10, so we reject H0; there is sufficient evidence that fish oil is effective in reducing heart attacks. 6.2. INFERENCE FOR THE DIFFERENCE OF TWO PROPORTIONS 321 6.2.6 Technology: the 2-proportion Z-test TI-83/84: 2-PROPORTION Z-TEST Use STAT, TESTS, 2-PropZTest. 1. Choose STAT. 2. Right arrow to TESTS. 3. Down arrow and choose 6:2-PropZTest. 4. Let x1 be the number of yeses (must be an integer) in sample 1 and let n1 be the size of sample 1. 5. Let x2 be the number of yeses (must be an integer) in sample 2 and let n2 be the size of sample 2. 6. Choose =
|
, <, or > to correspond to HA. 7. Choose Calculate and hit ENTER, which returns: z ^p1 ^p2 Z-statistic sample 1 proportion sample 2 proportion p ^p p-value pooled sample proportion CASIO FX-9750GII: 2-PROPORTION Z-TEST 1. Navigate to STAT (MENU button, then hit the 2 button or select STAT). 2. Choose the TEST option (F3 button). 3. Choose the Z option (F1 button). 4. Choose the 2-P option (F4 button). 5. Specify the test details: • Specify the sidedness of the test using the F1, F2, and F3 keys. • Enter the number of successes for each group, x1 and x2. • Enter the sample size for each group, n1 and n2. 6. Hit the EXE button, which returns z Z-statistic p-value p ^p1, ^p2 ^p n1, n2 sample proportions pooled proportion sample sizes GUIDED PRACTICE 6.27 Use a calculator to find the test statistic, p-value, and pooled proportion for a test with: HA: p for fish oil < p for placebo.20 fish oil placebo heart attack 145 200 no event Total 12933 12938 12788 12738 20Correctly going through the calculator steps should lead to a solution with the test statistic z = -2.977 and the p-value p = 0.00145. These two values match our calculated values from the previous example to within rounding error. The pooled proportion is given as ^p = 0.0133. Note: values for x1 and x2 were given in the table. If, instead, proportions are given, find x1 and x2 by multiplying the proportions by the sample sizes and rounding the result to an integer. 322 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA Section summary In the previous section, we looked at inference for a single proportion. In this section, we compared two groups to each other with respect to a proportion or a percent. • We are interested in whether the true proportion of yeses is the same or different between two distinct groups. Call these proportions p1 and p2. The difference, p1 − p2 tells us whether p1 is greater than
|
, less than, or equal to p2. • When comparing two proportions to each other, the parameter of interest is the difference of proportions, p1 − p2, and we use the difference of sample proportions, ˆp1 − ˆp2, as the point estimate. • The sampling distribution for ˆp1 − ˆp2 is nearly normal when the success-failure condition is met for both groups and when the observations are independent between and within groups. When the sampling distribution for ˆp1 − ˆp2 is nearly normal, the standardized test statistic also follows a normal distribution. • When the null hypothesis is that the two populations proportions are equal to each other, use the pooled sample proportion ˆpc = x1+x2, i.e. the combined number of yeses over the n1+n2 combined sample sizes, when verifying the success-failure condition and when finding the SE. For the confidence interval, do not use the pooled sample proportion; use the separate values of ˆp1 and ˆp2. • When there are two samples or treatments and the parameter of interest is a difference of proportions, e.g. the true difference in proportion of 17 and 18 year olds with a summer job (proportion of 18 year olds − proportion of 17 year olds): – Estimate p1 − p2 at the C% confidence level using a 2-proportion Z-interval. – Test H0: p1 − p2 = 0 at the α significance level using a 2-proportion Z-test. • The two proportion Z-interval and Z-test require the sampling distribution for ˆp1 − ˆp2 to be nearly normal. For this reason we must check that the following conditions are met. 1. Independence: Data come from 2 independent random samples or from a randomized experiment with 2 treatments. When sampling without replacement, check that the sample size is less than 10% of the population size for both samples. 2. Success-failure for CI: n1 ˆp1 ≥ 10, n1(1 − ˆp1) ≥ 10, n2 ˆp2 ≥ 10, and n2(1 − �
|
�p2) ≥ 10. Success-failure for Test: n1 ˆpc ≥ 10, n1(1 − ˆpc) ≥ 10, n2 ˆpc ≥ 10, and n2(1 − ˆpc) ≥ 10. • When the conditions are met, we calculate the confidence interval and the test statistic using the same structure as in the previous section. Confidence interval: point estimate ± z × SE of estimate Test statistic: Z = point estimate − null value SE of estimate Here the point estimate is the difference of sample proportions ˆp1 − ˆp2. The SE of estimate is the SE of a difference of sample proportions. – For a CI, use: SE = – For a Test, use: SE = ˆpc(1 − ˆpc). + ˆp2(1− ˆp2) n2 1 n1 + 1 n2. ˆp1(1− ˆp1) n1 6.2. INFERENCE FOR THE DIFFERENCE OF TWO PROPORTIONS 323 Exercises 6.15 Social experiment, Part I. A “social experiment” conducted by a TV program questioned what people do when they see a very obviously bruised woman getting picked on by her boyfriend. On two different occasions at the same restaurant, the same couple was depicted. In one scenario the woman was dressed “provocatively” and in the other scenario the woman was dressed “conservatively”. The table below shows how many restaurant diners were present under each scenario, and whether or not they intervened. Scenario Provocative Conservative Total Intervene Yes No Total 5 15 20 15 10 25 20 25 45 Explain why the sampling distribution for the difference between the proportions of interventions under provocative and conservative scenarios does not follow an approximately normal distribution. 6.16 Heart transplant success. The Stanford University Heart Transplant Study was conducted to determine whether an experimental heart transplant program increased lifespan. Each patient entering the program was officially designated a heart transplant candidate, meaning that he was gravely ill and might benefit from a new heart. Patients were randomly assigned into treatment and control groups. Patients in the treatment group received a transplant, and those in the control group did
|
not. The table below displays how many patients survived and died in each group.21 survived died control 4 30 treatment 24 45 Suppose we are interested in estimating the difference in survival rate between the control and treatment groups using a confidence interval. Explain why we cannot construct such an interval using the normal approximation. What might go wrong if we constructed the confidence interval despite this problem? 6.17 Gender and color preference. A study asked 1,924 male and 3,666 female undergraduate college students their favorite color. A 95% confidence interval for the difference between the proportions of males and females whose favorite color is black (pmale − pf emale) was calculated to be (0.02, 0.06). Based on this information, determine if the following statements about undergraduate college students are true or false, and explain your reasoning for each statement you identify as false.22 (a) We are 95% confident that the true proportion of males whose favorite color is black is 2% lower to 6% higher than the true proportion of females whose favorite color is black. (b) We are 95% confident that the true proportion of males whose favorite color is black is 2% to 6% higher than the true proportion of females whose favorite color is black. (c) 95% of random samples will produce 95% confidence intervals that include the true difference between the population proportions of males and females whose favorite color is black. (d) We can conclude that there is a significant difference between the proportions of males and females whose favorite color is black and that the difference between the two sample proportions is too large to plausibly be due to chance. (e) The 95% confidence interval for (pf emale − pmale) cannot be calculated with only the information given in this exercise. 21B. Turnbull et al. “Survivorship of Heart Transplant Data”. In: Journal of the American Statistical Association 69 (1974), pp. 74–80. 22L Ellis and C Ficek. “Color preferences according to gender and sexual orientation”. In: Personality and Individual Differences 31.8 (2001), pp. 1375–1379. 324 CHAPTER 6. IN
|
FERENCE FOR CATEGORICAL DATA 6.18 The Daily Show. A Pew Research foundation poll indicates that among a random sample of 1,099 college graduates, 33% watch The Daily Show. Meanwhile, 22% of the 1,110 people with a high school degree but no college degree in the poll watch The Daily Show. A 95% confidence interval for (pcollege grad − pHS or less), where p is the proportion of those who watch The Daily Show, is (0.07, 0.15). Based on this information, determine if the following statements are true or false, and explain your reasoning if you identify the statement as false.23 (a) At the 5% significance level, the data provide convincing evidence of a difference between the proportions of college graduates and those with a high school degree or less who watch The Daily Show. (b) We are 95% confident that 7% less to 15% more college graduates watch The Daily Show than those with a high school degree or less. (c) 95% of random samples of 1,099 college graduates and 1,110 people with a high school degree or less will yield differences in sample proportions between 7% and 15%. (d) A 90% confidence interval for (pcollege grad − pHS or less) would be wider. (e) A 95% confidence interval for (pHS or less − pcollege grad) is (-0.15,-0.07). 6.19 National Health Plan, Part III. Exercise 6.9 presents the results of a poll evaluating support for a generically branded “National Health Plan” in the United States. 79% of 347 Democrats and 55% of 617 Independents support a National Health Plan. (a) Calculate a 95% confidence interval for the difference between the proportion of Democrats and Independents who support a National Health Plan (pD − pI ), and interpret it in this context. We have already checked conditions for you. (b) True or false: If we had picked a random Democrat and a random Independent at the time of this poll, it is more likely that the Democrat would support the National Health Plan than the Independent. 6.20 Sleep deprivation, CA vs. OR, Part I. According to a report on
|
sleep deprivation by the Centers for Disease Control and Prevention, the proportion of California residents who reported insufficient rest or sleep during each of the preceding 30 days is 8.0%, while this proportion is 8.8% for Oregon residents. These data are based on simple random samples of 11,545 California and 4,691 Oregon residents. Calculate a 95% confidence interval to estimate the difference between the proportions of Californians and Oregonians who are sleep deprived. Include all steps of the Identify, Choose, Check, Calculate, Conclude framework.24 6.21 Sleep deprived transportation workers. The National Sleep Foundation conducted a survey on the sleep habits of randomly sampled transportation workers and randomly sampled non-transportation workers that serve as a “control” for comparison. The results of the survey are shown below.25 Transportation Professionals Train Truck Less than 6 hours of sleep 6 to 8 hours of sleep More than 8 hours Total Control 35 193 64 292 Pilots Drivers Operators 19 132 51 202 35 117 51 203 29 119 32 180 Bus/Taxi/Limo Drivers 21 131 58 210 Conduct a hypothesis test to evaluate if these data provide evidence of a difference between the proportion of truck drivers and non-transportation workers (the “control” group) who get less than 6 hours of sleep per day (i.e. are considered sleep deprived). Include all steps of the Identify, Choose, Check, Calculate, Conclude framework. 23The Pew Research Center, Americans Spending More Time Following the News, data collected June 8-28, 2010. 24CDC, Perceived Insufficient Rest or Sleep Among Adults — United States, 2008. 25National Sleep Foundation, 2012 Sleep in America Poll: Transportation Workers’ Sleep, 2012. 6.2. INFERENCE FOR THE DIFFERENCE OF TWO PROPORTIONS 325 6.22 Sleep deprivation, CA vs. OR, Part II. Exercise 6.20 provides data on sleep deprivation rates of Californians and Oregonians. The proportion of California residents who reported insufficient rest or sleep during each of the preceding 30 days is 8.0%, while this proportion is 8.8% for Oregon residents. These data are based on simple random samples of 11,545 California and 4,691 Oregon residents. (a) Conduct a hypothesis test to determine if these data provide strong evidence that the rate of sleep deprivation is di
|
fferent for the two states. (Reminder: Check conditions) (b) It is possible the conclusion of the test in part (a) is incorrect. If this is the case, what type of error was made? 6.23 Prenatal vitamins and Autism. Researchers studying the link between prenatal vitamin use and autism surveyed the mothers of a random sample of children aged 24 - 60 months with autism and conducted another separate random sample for children with typical development. The table below shows the number of mothers in each group who did and did not use prenatal vitamins during the three months before pregnancy (periconceptional period).26 Autism Periconceptional No vitamin prenatal vitamin Vitamin 111 143 254 (a) State appropriate hypotheses to test for independence of use of prenatal vitamins during the three Autism Typical development Total 181 70 302 159 483 229 Total months before pregnancy and autism. (b) Complete the hypothesis test and state an appropriate conclusion. (Reminder: Verify any necessary conditions for the test.) (c) A New York Times article reporting on this study was titled “Prenatal Vitamins May Ward Off Autism”. Do you find the title of this article to be appropriate? Explain your answer. Additionally, propose an alternative title.27 6.24 An apple a day keeps the doctor away. A physical education teacher at a high school wanting to increase awareness on issues of nutrition and health asked her students at the beginning of the semester whether they believed the expression “an apple a day keeps the doctor away”, and 40% of the students responded yes. Throughout the semester she started each class with a brief discussion of a study highlighting positive effects of eating more fruits and vegetables. She conducted the same apple-a-day survey at the end of the semester, and this time 60% of the students responded yes. Can she used a two-proportion method from this section for this analysis? Explain your reasoning. 26R.J. Schmidt et al. “Prenatal vitamins, one-carbon metabolism gene variants, and risk for autism”. In: Epidemi- ology 22.4 (2011), p. 476. 27R.C. Rabin. “Patterns: Prenatal Vitamins May Ward Off Autism”. In: New York Times (2011). 326 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.3 Testing for goodness of
|
fit using chi-square In this section, we develop a method for assessing a null model when the data take on more than two categories, such as yes/no/maybe instead of simply yes/no. This allows us to answer questions such as the following: • Are juries representative of the population in terms of race/ethnicity, or is there a bias in jury selection? • Is the color distribution of actual M&M’s consistent with what was reported on the Mars website? • Do people choose rock, paper, scissors with the same likelihood, or is one choice favored over another? Learning objectives 1. Calculate the expected counts and degrees of freedom for a one-way table. 2. Calculate and interpret the test statistic χ2. 3. State and verify whether or not the conditions for the chi-square goodness of fit are met. 4. Carry out a complete hypothesis test to evaluate if the distribution of a categorical variable follows a hypothesized distribution. 5. Understand how the degrees of freedom affect the shape of the chi-square curve. 6.3.1 Creating a test statistic for one-way tables Data is collected from a random sample of 275 jurors in a small county. Jurors identified their racial/ethnic group, as shown in Figure 6.4, and we would like to determine if these jurors are representative of the population with respect to race/ethnicity. If the jury is representative of the population, then the proportions in the sample should roughly reflect the population of eligible jurors, i.e. registered voters. Race/Ethnicity Representation in juries Registered voters White Black Hispanic Other 205 0.72 26 0.07 25 0.12 19 0.09 Total 275 1.00 Figure 6.4: Representation by race in a city’s juries and population. While the proportions in the juries do not precisely represent the population proportions, it is unclear whether these data provide convincing evidence that the sample is not representative. If the jurors really were randomly sampled from the registered voters, we might expect small differences due to chance. However, unusually large differences may provide convincing evidence that the juries were not representative. 6.3. TESTING FOR GOODNESS OF FIT USING CHI-SQUARE 327 EXAMPLE 6.28 Of the people in the city, 275 served on a jury.
|
If the individuals are randomly selected to serve on a jury, about how many of the 275 people would we expect to be White? How many would we expect to be Black? About 72% of the population is White, so we would expect about 72% of the jurors to be White: 0.72 × 275 = 198. Similarly, we would expect about 7% of the jurors to be Black, which would correspond to about 0.07 × 275 = 19.25 Black jurors. GUIDED PRACTICE 6.29 Twelve percent of the population is Hispanic and 9% represent other racial/ethnic groups. How many of the 275 jurors would we expect to be Hispanic or from another racial/ethnic group? Answers can be found in Figure 6.5. Race/Ethnicity Observed data Expected counts White Black Hispanic Other 205 198 26 19.25 25 33 19 24.75 Total 275 275 Figure 6.5: Actual and expected make-up of the jurors. The sample proportion represented from each race/ethnicity among the 275 jurors was not a precise match for any ethnic group. While some sampling variation is expected, we would expect the sample proportions to be fairly similar to the population proportions if there is no bias on juries. We need to test whether the differences are strong enough to provide convincing evidence that the jurors are not a random sample. These ideas can be organized into hypotheses: H0: The jurors are a random sample, i.e. there is no racial/ethnic bias in who serves on a jury, and the observed counts reflect natural sampling fluctuation. HA: The jurors are not randomly sampled, i.e. there is racial/ethnic bias in juror selection. To evaluate these hypotheses, we quantify how different the observed counts are from the expected counts. Strong evidence for the alternative hypothesis would come in the form of unusually large deviations in the groups from what would be expected based on sampling variation alone. 6.3.2 The chi-square test statistic In previous hypothesis tests, we constructed a test statistic of the following form: Z = point estimate − null value SE of point estimate This construction was based on (1) identifying the difference between a point estimate and an expected value if the null hypothesis was true, and (2) standardizing that difference using the standard error of the point estimate. These two ideas will help in the construction of an appropriate test statistic for count
|
data. In this example we have four categories: White, Black, Hispanic, and other. Because we have four values rather than just one or two, we need a new tool to analyze the data. Our strategy will be to find a test statistic that measures the overall deviation between the observed and the expected counts. We first find the difference between the observed and expected counts for the four groups: observed - expected 205 − 198 26 − 19.25 White Black Hispanic 25 − 33 Other 19 − 24.75 328 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA Next, we square the differences: (observed - expected)2 White (205 − 198)2 Black (26 − 19.25)2 Hispanic (25 − 33)2 Other (19 − 24.75)2 We must standardize each term. To know whether the squared difference is large, we compare it to what was expected. If the expected count was 5, a squared difference of 25 is very large. However, if the expected count was 1,000, a squared difference of 25 is very small. We will divide each of the squared differences by the corresponding expected count. (observed - expected)2 expected (205 − 198)2 198 (26 − 19.25)2 19.25 (25 − 33)2 33 (19 − 24.75)2 24.75 White Black Hispanic Other Finally, to arrive at the overall measure of deviation between the observed counts and the expected counts, we add up the terms. χ2 = (observed - expected)2 expected = (205 − 198)2 198 + (26 − 19.25)2 19.25 + (25 − 33)2 33 + (19 − 24.75)2 24.75 We can write an equation for χ2 using the observed counts and expected counts: χ2 = (observed count1 − expected count1)2 expected count1 + · · · + (observed count4 − expected count4)2 expected count4 The final number χ2 summarizes how strongly the observed counts tend to deviate from the null counts. In Section 6.3.4, we will see that if the null hypothesis is true, then χ2 follows a new distribution called a chi-square distribution. Using this
|
distribution, we will be able to obtain a p-value to evaluate whether there appears to be racial/ethnic bias in the juries for the city we are considering. 6.3.3 The chi-square distribution and finding areas The chi-square distribution is sometimes used to characterize data sets and statistics that are always positive and typically right skewed. Recall a normal distribution had two parameters – mean and standard deviation – that could be used to describe its exact characteristics. The chisquare distribution has just one parameter called degrees of freedom (df ), which influences the shape, center, and spread of the distribution. GUIDED PRACTICE 6.30 Figure 6.6 shows three chi-square distributions. (a) How does the center of the distribution change when the degrees of freedom is larger? (b) What about the variability (spread)? (c) How does the shape change?28 Figure 6.6 and Guided Practice 6.30 demonstrate three general properties of chi-square distributions as the degrees of freedom increases: the distribution becomes more symmetric, the center moves to the right, and the variability inflates. 28(a) The center becomes larger. If we look carefully, we can see that the center of each distribution is equal to the distribution’s degrees of freedom. (b) The variability increases as the degrees of freedom increases. (c) The distribution is very strongly right skewed for df = 2, and then the distributions become more symmetric for the larger degrees of freedom df = 4 and df = 9. In fact, as the degrees of freedom increase, the χ2 distribution approaches a normal distribution. 6.3. TESTING FOR GOODNESS OF FIT USING CHI-SQUARE 329 Figure 6.6: Three chi-square distributions with varying degrees of freedom. Our principal interest in the chi-square distribution is the calculation of p-values, which (as we have seen before) is related to finding the relevant area in the tail of a distribution. To do so, a new table is needed: the chi-square table, partially shown in Figure C.5. A more complete table is presented in Appendix C.4 on page 518. This table is very similar to the t-table from Sections 7.1 and 7.3: we identify a range for the area, and we examine a particular row for distributions with different degrees of freedom
|
. One important difference from the t-table is that the chi-square table only provides upper tail values. Upper tail 1 df 2 3 4 5 6 7 0.3 1.07 2.41 3.66 4.88 6.06 7.23 8.38 0.2 1.64 3.22 4.64 5.99 7.29 8.56 9.80 0.1 2.71 4.61 6.25 7.78 9.24 10.64 12.02 0.05 3.84 5.99 7.81 9.49 11.07 12.59 14.07 0.02 5.41 7.82 9.84 11.67 13.39 15.03 16.62 0.01 6.63 9.21 11.34 13.28 15.09 16.81 18.48 0.005 7.88 10.60 12.84 14.86 16.75 18.55 20.28 0.001 10.83 13.82 16.27 18.47 20.52 22.46 24.32 Figure 6.7: A section of the chi-square table. A complete table is in Appendix C.4. EXAMPLE 6.31 Figure 6.8(a) shows a chi-square distribution with 3 degrees of freedom and an upper shaded tail starting at 6.25. Use Figure C.5 to estimate the shaded area. This distribution has three degrees of freedom, so only the row with 3 degrees of freedom (df) is relevant. This row has been italicized in the table. Next, we see that the value – 6.25 – falls in the column with upper tail area 0.1. That is, the shaded upper tail of Figure 6.8(a) has area 0.1. EXAMPLE 6.32 We rarely observe the exact value in the table. For instance, Figure 6.8(b) shows the upper tail of a chi-square distribution with 2 degrees of freedom. The lower bound for this upper tail is at 4.3, which does not fall in Figure C.5. Find the approximate tail area. The cutoff 4.3 falls between the second and third columns in the 2 degrees of freedom row. Because these columns correspond to tail areas of 0.2 and 0.1, we can be certain that the area shaded in Figure 6.8(b) is between 0
|
.1 and 0.2. Using a calculator or statistical software allows us to get more precise areas under the chi-square curve than we can get from the table alone. 0510152025Degrees of Freedom249 330 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA (a) (c) (e) (b) (d) (f) Figure 6.8: (a) Chi-square distribution with 3 degrees of freedom, area above 6.25 shaded. (b) 2 degrees of freedom, area above 4.3 shaded. (c) 5 degrees of freedom, area above 5.1 shaded. (d) 7 degrees of freedom, area above 11.7 shaded. (e) 4 degrees of freedom, area above 10 shaded. (f ) 3 degrees of freedom, area above 9.21 shaded. 051015202505101520250510152025051015202505101520250510152025 6.3. TESTING FOR GOODNESS OF FIT USING CHI-SQUARE 331 TI-84: FINDING AN UPPER TAIL AREA UNDER THE CHI-SQUARE CURVE Use the χ2cdf command to find areas under the chi-square curve. 1. Hit 2ND VARS (i.e. DISTR). 2. Choose 8:χ2cdf. 3. Enter the lower bound, which is generally the chi-square value. 4. Enter the upper bound. Use a large number, such as 1000. 5. Enter the degrees of freedom. 6. Choose Paste and hit ENTER. TI-83: Do steps 1-2, then type the lower bound, upper bound, and degrees of freedom separated by commas. e.g. χ2cdf(5, 1000, 3), and hit ENTER. CASIO FX-9750GII: FINDING AN UPPER TAIL AREA UNDER THE CHI-SQ. CURVE 1. Navigate to STAT (MENU button, then hit the 2 button or select STAT). 2. Choose the DIST option (F5 button). 3. Choose the CHI option (F3 button). 4. Choose the Ccd option (F2 button). 5. If necessary, select the Var option (F2 button). 6. Enter the Lower bound (generally the chi-square
|
value). 7. Enter the Upper bound (use a large number, such as 1000). 8. Enter the degrees of freedom, df. 9. Hit the EXE button. GUIDED PRACTICE 6.33 Figure 6.8(c) shows an upper tail for a chi-square distribution with 5 degrees of freedom and a cutoff of 5.1. Find the tail area using a calculator.29 GUIDED PRACTICE 6.34 Figure 6.8(d) shows a cutoff of 11.7 on a chi-square distribution with 7 degrees of freedom. Find the area of the upper tail.30 GUIDED PRACTICE 6.35 Figure 6.8(e) shows a cutoff of 10 on a chi-square distribution with 4 degrees of freedom. Find the area of the upper tail.31 GUIDED PRACTICE 6.36 Figure 6.8(f) shows a cutoff of 9.21 with a chi-square distribution with 3 df. Find the area of the upper tail.32 29Use a lower bound of 5.1, an upper bound of 1000, and df = 5. The upper tail area is 0.4038. 30The area is 0.1109. 31The area is 0.0404. 32The area is 0.0266. 332 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.3.4 Finding a p-value for a chi-square distribution In Section 6.3.2, we identified a new test statistic (χ2) within the context of assessing whether there was evidence of racial/ethnic bias in how jurors were sampled. The null hypothesis represented the claim that jurors were randomly sampled and there was no racial/ethnic bias. The alternative hypothesis was that there was racial/ethnic bias in how the jurors were sampled. We determined that a large χ2 value would suggest strong evidence favoring the alternative hypothesis: that there was racial/ethnic bias. However, we could not quantify what the chance was of observing such a large test statistic (χ2 = 5.89) if the null hypothesis actually was true. This is where the chi-square distribution becomes useful. If the null hypothesis was true and there was no racial/ethnic bias, then χ2 would follow a chi-square distribution, with three degrees of freedom in this case. Under certain conditions, the
|
statistic χ2 follows a chi-square distribution with k − 1 degrees of freedom, where k is the number of bins or categories of the variable. EXAMPLE 6.37 How many categories were there in the juror example? How many degrees of freedom should be associated with the chi-square distribution used for χ2? In the jurors example, there were k = 4 categories: White, Black, Hispanic, and other. According to the rule above, the test statistic χ2 should then follow a chi-square distribution with k − 1 = 3 degrees of freedom if H0 is true. Just like we checked sample size conditions to use the normal model in earlier sections, we must also check a sample size condition to safely model χ2 with a chi-square distribution. Each expected count must be at least 5. In the juror example, the expected counts were 198, 19.25, 33, and 24.75, all easily above 5, so we can model the χ2 test statistic, using a chi-square distribution. EXAMPLE 6.38 If the null hypothesis is true, the test statistic χ2 = 5.89 would be closely associated with a chisquare distribution with three degrees of freedom. Using this distribution and test statistic, identify the p-value and state whether or not there is evidence of racial/ethnic bias in the juror selection. The chi-square distribution and p-value are shown in Figure 6.9. Because larger chi-square values correspond to stronger evidence against the null hypothesis, we shade the upper tail to represent the p-value. Using a calculator, we look at the chi-square curve with 3 degrees of freedom and find the area to the right of χ2 = 5.89. This area, which corresponds to the p-value, is equal to 0.117. This p-value is larger than the default significance level of 0.05, so we do not reject the null hypothesis. In other words, the data do not provide convincing evidence of racial/ethnic bias in the juror selection. Figure 6.9: The p-value for the juror hypothesis test is shaded in the chi-square distribution with df = 3. The test that we just carried out regarding jury selection is known as the χ2χ2χ2 goodness of fit test. It is called “goodness of fit�
|
� because we test whether or not the proposed or expected distribution is a good fit for the observed data. 051015 6.3. TESTING FOR GOODNESS OF FIT USING CHI-SQUARE 333 CHI-SQUARE GOODNESS OF FIT TEST FOR ONE-WAY TABLE Suppose we are to evaluate whether there is convincing evidence that a set of observed counts O1, O2,..., Ok in k categories are unusually different from what might be expected under a null hypothesis. Calculate the expected counts that are based on the null hypothesis E1, E2,..., Ek. If each expected count is at least 5 and the null hypothesis is true, then the test statistic below follows a chi-square distribution with k − 1 degrees of freedom: χ2 = (O1 − E1)2 E1 + (O2 − E2)2 E2 + · · · + (Ok − Ek)2 Ek The p-value for this test statistic is found by looking at the upper tail of this chi-square distribution. We consider the upper tail because larger values of χ2 would provide greater evidence against the null hypothesis. CONDITIONS FOR THE CHI-SQUARE GOODNESS OF FIT TEST The chi-square goodness of fit test requires the test statistic to be well modeled by a chi-square distribution. This will be valid when the observations are independent and the expected counts are large. If these conditions are not met, the chi-square goodness of fit test should not be used. Independence. The observations can be considered independent if the data come from a random process. If randomly sampling without replacement from a finite population, the observations can be considered independent when sampling less than 10% of the population. Large expected counts. In order for the χ2-statistic to follow the chi-square distribution, each particular bin or category must have at least 5 expected cases under the assumption that the null hypothesis is true. 334 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.3.5 Evaluating goodness of fit for a distribution GOODNESS OF FIT TEST FOR A ONE-WAY TABLE When there is one sample and we are comparing the distribution of a categorical variable to a specified or population distribution, e.g. using sample values to determine if a machine is producing M&M’s
|
with the specified distribution of color, Identify: Identify the hypotheses and the significance level, α. H0: The distribution of [...] matches the specified or population distribution. HA: The distribution of [...] doesn’t match the specified or population distribution. Choose: Choose the correct test procedure and identify it by name. Here we use a χ2χ2χ2 goodness of fit test. Check: Check that the test statistic follows a chi-square distribution. 1. Independence: Data come from a random sample or random process. If sampling without replacement, check that the sample size is less than 10% of the population size. 2. Expected counts: All expected counts are ≥ 5. Calculate: Calculate the χ2-statistic, df, and p-value. test statistic: χ2 = (observed − expected)2 df = # of categories − 1 p-value = (area to the right of χ2-statistic with the appropriate df ) expected Conclude: Compare the p-value to α, and draw a conclusion in context. If the p-value is < α, reject H0; there is sufficient evidence that [HA in context]. If the p-value is > α, do not reject H0; there is not sufficient evidence that [HA in context]. Have you ever wondered about the color distribution of M&M’s®? If so, then you will be glad to know that Rick Wicklin, a statistician working at the statistical software company SAS, wondered about this too. But he did more than wonder; he decided to collect data to test whether the distribution of M&M colors was consistent with the stated distribution published on the Mars website in 2008. Starting at end of 2016, over the course of several weeks, he collected a sample of 712 candies, or about 1.5 pounds. We will investigate his results in the next example. You can read about his adventure in the Quartz article linked in the Data Appendix, which starts on page 503. 6.3. TESTING FOR GOODNESS OF FIT USING CHI-SQUARE 335 EXAMPLE 6.39 The stated color distribution of M&M’s on the Mars website in 2008 is shown in the table below, along with the observed percentages from Rick Wick
|
lin’s sample of size 712. (See the paragraph before this example for more background.) website percentages (2008): observed percentages: Brown Blue 24% 13% 18.7% 18.7% 19.5% 14.5% 15.1% 13.5% Orange Green Yellow 16% Red 13% 14% 20% Is there evidence at the 5% significance level that the distribution of M&M’s in 2016 were different from the stated distribution on the website in 2008? Use the five step framework to organize your work. Identify: We will test the following hypotheses at the α = 0.05 significance level. H0: The distribution of M&M colors is the same as the stated distribution in 2008. HA: The distribution of M&M colors is different than the stated distribution in 2008. Choose: Because we have one variable (color), broken up into multiple categories, we choose the chi-square goodness of fit test. Check: We must verify that the test statistic follows a chi-square distribution. Note that there is only one sample here. The website percentages are considered fixed – they are not the result of a sample and do not have sampling variability associated with them. To carry out the chi-square goodness of fit test, we will have to assume that Wicklin’s sample can be considered a random sample of M&M’s. We note that the total population size of M&M’s is much larger than 10 times the sample size of 712. Next, we need to find the expected counts. Here, n = 712. If H0 is true, then we would expect 24% of the M&M’s to be Blue, 20% to be Orange, etc. So the expected counts can be found as: expected counts: Blue 0.24(712) = 170.9 Orange 0.20(712) = 142.4 Green 0.16(712) = 113.9 Yellow 0.14(712) = 99.6 Red 0.13(712) = 92.6 Brown 0.13(712) = 92.6 Calculate: We will calculate the chi-square statistic, degrees of freedom, and the p-value. To calculate the chi-square statistic, we need the observed
|
counts as well as the expected counts. To find the observed counts, we use the observed percentages. For example, 18.7% of 712 = 0.187(712) = 133. observed counts: expected counts: Blue Orange Green Yellow Red Brown 133 170.9 139 113.9 133 142.4 108 92.6 96 92.6 103 99.6 χ2 = (observed − expected)2 expected = (133 − 170.9)2 170.9 + (133 − 142.4)2 142.4 + · · · + (108 − 92.6)2 92.6 + (96 − 92.6)2 92.6 =8.41 + 0.62 + 5.53 + 0.12 + 2.56 + 0.12 =17.36 Because there are six colors, the degrees of freedom is 6 − 1 = 5. In a chi-square test, the p-value is always the area to the right of the chi-square statistic. Here, the area to the right of 17.36 under the chi-square curve with 5 degrees of freedom is 0.004. Conclude: The p-value of 0.004 is < 0.05, so we reject H0; there is sufficient evidence that the distribution of M&M’s does not match the stated distribution on the website in 2008. 336 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA EXAMPLE 6.40 For Wicklin’s sample, which color showed the most prominent difference from the stated website distribution in 2008? We can compare the website percentages with the observed percentages. However, another approach is to look at the terms used when calculating the chi-square statistic. We note that the largest term, 8.41, corresponds to Blue. This means that the observed number for Blue was, relatively speaking, the farthest from the expected number among all of the colors. This is consistent with the observation that the largest difference in website percentage and observed percentage is for Blue (24% vs 18.7%). Wicklin observed far fewer Blue M&M’s than would have been expected if the website percentages were still true. 6.3. TESTING FOR GOODNESS OF FIT USING CHI-SQUARE 337 6.3.6 Technology: the chi-square goodness of fit test TI-84:
|
CHI-SQUARE GOODNESS OF FIT TEST Use STAT, TESTS, χ2GOF-Test. 1. Enter the observed counts into list L1 and the expected counts into list L2. 2. Choose STAT. 3. Right arrow to TESTS. 4. Down arrow and choose D:χ2GOF-Test. 5. Leave Observed: L1 and Expected: L2. 6. Enter the degrees of freedom after df: 7. Choose Calculate and hit ENTER, which returns: χ2 p df chi-square test statistic p-value degrees of freedom TI-83: Unfortunately the TI-83 does not have this test built in. To carry out the test manually, make list L3 = (L1 - L2)2 / L2 and do 1-Var-Stats on L3. The sum of L3 will correspond to the value of χ2 for this test. CASIO FX-9750GII: CHI-SQUARE GOODNESS OF FIT TEST 1. Navigate to STAT (MENU button, then hit the 2 button or select STAT). 2. Enter the observed counts into a list (e.g. List 1) and the expected counts into list (e.g. List 2). 3. Choose the TEST option (F3 button). 4. Choose the CHI option (F3 button). 5. Choose the GOF option (F1 button). 6. Adjust the Observed and Expected lists to the corresponding list numbers from Step 2. 7. Enter the degrees of freedom, df. 8. Specify a list where the contributions to the test statistic will be reported using CNTRB. This list number should be different from the others. 9. Hit the EXE button, which returns chi-square test statistic p-value degrees of freedom list showing the test statistic contributions χ2 p df CNTRB GUIDED PRACTICE 6.41 Use the table below and a calculator to find the χ2-statistic and p-value for chi-square goodness of fit test.33 observed counts: expected counts: Blue Orange Green Yellow Red Brown 133 170.9 139 113.9 133 142.4 103 99.6 108 92.6 96 92.6 33Enter the observed counts into L1 and the expected counts into L2. the GOF test. Make sure that Observed
|
: is L1 and Expected: is L2. Let df: be 5. You should find that χ2 = 17.36 and p-value = 0.004. 338 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA Section summary The inferential procedures we saw in the first two sections of this chapter are based on the test statistic following a normal distribution. In this section, we introduced a new distribution called the chi-square distribution. • While a normal distribution is defined by its mean and standard deviation, the chi-square distribution is defined by just one parameter called degrees of freedom. • For a chi-square distribution, as the degrees of freedom increases: the center increases, the spread increases, and the shape becomes more symmetric and more normal.34 • When we want to see if a model is a good fit for observed data or if data is representative of a particular population, we can use a χ2χ2χ2 goodness of fit test. This test is used when there is one variable with multiple categories (bins) that can be arranged in a one-way table. • In a chi-square goodness of fit test, we calculate a χ2χ2χ2-statistic, which is a measure of how far the observed counts in the sample are from the expected counts, relative to the expected counts, under the null hypothesis. χ2 = (observed − expected)2. expected – Always use whole numbers (counts) for the observed values, not proportions or percents. – For each category, the expected counts can be found by multiplying the sample size by the expected proportion under the null hypothesis. Expected counts do not need to be integers. • A larger χ2 represents greater deviation between the observed values and the expected values, relative to the expected values. For a fixed degrees of freedom, a larger χ2 value leads to a smaller p-value, providing greater evidence against H0. • χ2χ2χ2 tests for a one-way table. When there is one sample and we are comparing the distribution of a categorical variable to a specified or population distribution, e.g. using sample values to determine if a machine is producing M&M’s with the specifi
|
ed distribution of color, the hypotheses can often be written as: H0: The distribution of [...] matches the specified or population distribution. HA: The distribution of [...] doesn’t match the specified or population distribution. We test these hypotheses at the α significance level using a χ2χ2χ2 goodness of fit test. • For the χ2 goodness of fit test, we check the following conditions to verify that the test statistic follows a chi-square distribution. 1. Independence: Data come from a random sample or random process. When sampling without replacement, check that sample size is less than 10% of the population size. 2. Expected counts: All expected counts are ≥ 5. • We calculate the test statistic as follows: test statistic: χ2 = (observed − expected)2 expected ; df = # of categories − 1 • The p-value is the area to the right of the χ2-statistic under the chi-square curve with the appropriate df. • For a χ2 test, the p-value corresponds to the probability of getting a test statistic as large as we got or larger, assuming the null hypothesis is true and assuming the chi-square model holds. 34Technically, however, it is always right skewed. 6.3. TESTING FOR GOODNESS OF FIT USING CHI-SQUARE 339 Exercises 6.25 True or false, Part I. Determine if the statements below are true or false. For each false statement, suggest an alternative wording to make it a true statement. (a) The chi-square distribution, just like the normal distribution, has two parameters, mean and standard deviation. (b) The chi-square distribution is always right skewed, regardless of the value of the degrees of freedom parameter. (c) The chi-square statistic is always greater than or equal to 0. (d) As the degrees of freedom increases, the shape of the chi-square distribution becomes more skewed. 6.26 True or false, Part II. Determine if the statements below are true or false. For each false statement, suggest an alternative wording to make it a true statement. (a) As the degrees of freedom increases, the mean of the chi-square distribution increases. (b) If you found χ2 = 10 with df = 5 you would fail to reject H0
|
at the 5% significance level. (c) When finding the p-value of a chi-square test, we always shade the tail areas in both tails. (d) As the degrees of freedom increases, the variability of the chi-square distribution decreases. A professor using an open source introductory statistics book predicts 6.27 Open source textbook. that 60% of the students will purchase a hard copy of the book, 25% will print it out from the web, and 15% will read it online. At the end of the semester he asks his students to complete a survey where they indicate what format of the book they used. Of the 126 students, 71 said they bought a hard copy of the book, 30 said they printed it out from the web, and 25 said they read it online. (a) State the hypotheses for testing if the professor’s predictions were inaccurate. (b) How many students did the professor expect to buy the book, print the book, and read the book exclusively online? (c) List the conditions required for the chi-square goodness of fit test and discuss whether they are satisfied. (d) Assume conditions are sufficiently met. Calculate the chi-square statistic, the degrees of freedom asso- ciated with it, and the p-value. (e) Based on the p-value calculated in part (d), what is the conclusion of the hypothesis test? Interpret your conclusion in this context. 6.28 Barking deer. Microhabitat factors associated with forage and bed sites of barking deer in Hainan Island, China were examined. In this region woods make up 4.8% of the land, cultivated grass plot makes up 14.7%, and deciduous forests make up 39.6%. Of the 426 sites where the deer forage, 4 were categorized as woods, 16 as cultivated grassplot, and 61 as deciduous forests. The table below summarizes these data.35 Woods Cultivated grassplot Deciduous forests Other Total 426 345 61 16 4 (a) Do these data provide convincing evidence that barking deer prefer to forage in certain habitats over others? Conduct an appropriate hypothesis test to answer this research question, and acknowledge any assumptions you had to make to carry out this test. Include all steps of the Identify, Choose, Check, Calculate, Conclude framework. (b) Interpret the calculated
|
p-value in the context of the problem. Photo by Shrikant Rao (http://flic.kr/p/4Xjdkk) CC BY 2.0 license 35Liwei Teng et al. “Forage and bed sites characteristics of Indian muntjac (Muntiacus muntjak) in Hainan Island, China”. In: Ecological Research 19.6 (2004), pp. 675–681. 340 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.4 Chi-square tests in two-way tables We encounter two-way tables in this section, and we learn about two new and closely related chisquare tests. We will answer questions such as the following: • Does the phrasing of the question affect how likely sellers are to disclose problems with a product? • Is gender associated with whether Facebook users know how to adjust their privacy settings? • Is political affiliation associated with support for the use of full body scans at airports? Learning objectives 1. Calculate the expected counts and degrees of freedom for a chi-square test involving a two-way table. 2. State and verify whether or not the conditions for a chi-square test for a two-way table are met. 3. Explain the difference between the chi-square test for homogeneity and chi-square test for independence. 4. Carry out a complete hypothesis test for homogeneity and for independence. 6.4. HOMOGENEITY AND INDEPENDENCE IN TWO-WAY TABLES 341 6.4.1 Introduction to two-way tables Google is constantly running experiments to test new search algorithms. For example, Google might test three algorithms using a sample of 10,000 google.com search queries. Figure 6.10 shows an example of 10,000 queries split into three algorithm groups.36 The group sizes were specified before the start of the experiment to be 5000 for the current algorithm and 2500 for each test algorithm. Search algorithm Counts current 5000 test 1 2500 test 2 2500 Total 10000 Figure 6.10: Experiment breakdown of test subjects into three search groups. EXAMPLE 6.42 What is the ultimate goal of the Google experiment? What are the null and alternative hypotheses, in regular words? The ultimate goal is to see whether there is a difference in the performance of the algorithms. The hypotheses can be
|
described as the following: H0: The algorithms each perform equally well. HA: The algorithms do not perform equally well. In this experiment, the explanatory variable is the search algorithm. However, an outcome variable is also needed. This outcome variable should somehow reflect whether the search results align with the user’s interests. One possible way to quantify this is to determine whether (1) there was no new, related search, and the user clicked one of the links provided, or (2) there was a new, related search performed by the user. Under scenario (1), we might think that the user was satisfied with the search results. Under scenario (2), the search results probably were not relevant, so the user tried a second search. Figure 6.11 provides the results from the experiment. These data are very similar to the count data in Section 6.3. However, now the different combinations of two variables are binned in a twoway table. In examining these data, we want to evaluate whether there is strong evidence that at least one algorithm is performing better than the others. To do so, we apply a chi-square test to this two-way table. The ideas of this test are similar to those ideas in the one-way table case. However, degrees of freedom and expected counts are computed a little differently than before. No new search New search Total Search algorithm test 1 1749 751 2500 current 3511 1489 5000 test 2 1818 682 2500 Total 7078 2922 10000 Figure 6.11: Results of the Google search algorithm experiment. WHAT IS SO DIFFERENT ABOUT ONE-WAY TABLES AND TWO-WAY TABLES? A one-way table describes counts for each outcome in a single variable. A two-way table describes counts for combinations of outcomes for two variables. When we consider a two-way table, we often would like to know, are these variables related in any way? The hypothesis test for this Google experiment is really about assessing whether there is statistically significant evidence that the choice of the algorithm affects whether a user performs a second search. In other words, the goal is to check whether the three search algorithms perform differently. 36Google regularly runs experiments in this manner to help improve their search engine. It is entirely possible that if you perform a search and so does your friend,
|
that you will have different search results. While the data presented in this section resemble what might be encountered in a real experiment, these data are simulated. 342 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA 6.4.2 Expected counts in two-way tables EXAMPLE 6.43 From the experiment, we estimate the proportion of users who were satisfied with their initial search (no new search) as 7078/10000 = 0.7078. If there really is no difference among the algorithms and 70.78% of people are satisfied with the search results, how many of the 5000 people in the “current algorithm” group would be expected to not perform a new search? About 70.78% of the 5000 would be satisfied with the initial search: 0.7078 × 5000 = 3539 users That is, if there was no difference between the three groups, then we would expect 3539 of the current algorithm users not to perform a new search. GUIDED PRACTICE 6.44 Using the same rationale described in Example 6.43, about how many users in each test group would not perform a new search if the algorithms were equally helpful?37 We can compute the expected number of users who would perform a new search for each group using the same strategy employed in Example 6.43 and Guided Practice 6.44. These expected counts were used to construct Figure 6.12, which is the same as Figure 6.11, except now the expected counts have been added in parentheses. Search algorithm No new search New search Total current 3511 1489 5000 (3539) (1461) test 1 1749 751 2500 (1769.5) (730.5) test 2 1818 682 2500 (1769.5) (730.5) Total 7078 2922 10000 Figure 6.12: The observed counts and the (expected counts). The examples and exercises above provided some help in computing expected counts. In general, expected counts for a two-way table may be computed using the row totals, column totals, and the table total. For instance, if there was no difference between the groups, then about 70.78% of each column should be in the first row: 0.7078 × (column 1 total) = 3539 0.70
|
78 × (column 2 total) = 1769.5 0.7078 × (column 3 total) = 1769.5 Looking back to how the fraction 0.7078 was computed – as the fraction of users who did not perform a new search (7078/10000) – these three expected counts could have been computed as row 1 total table total row 1 total table total row 1 total table total (column 1 total) = 3539 (column 2 total) = 1769.5 (column 3 total) = 1769.5 This leads us to a general formula for computing expected counts in a two-way table when we would like to test whether there is strong evidence of an association between the column variable and row variable. 37We would expect 0.7078 ∗ 2500 = 1769.5. It is okay that this is a fraction. 6.4. HOMOGENEITY AND INDEPENDENCE IN TWO-WAY TABLES 343 COMPUTING EXPECTED COUNTS IN A TWO-WAY TABLE To identify the expected count for the ith row and jth column, compute Expected Countrow i, col j = (row i total) × (column j total) table total 6.4.3 The chi-square test for homogeneity in two-way tables The chi-square test statistic for a two-way table is found the same way it is found for a one-way table. For each table count, compute General formula Row 1, Col 1 Row 1, Col 2... Row 2, Col 3 (observed count − expected count)2 expected count (3511 − 3539)2 3539 (1749 − 1769.5)2 1769.5... (682 − 730.5)2 730.5 = 0.222 = 0.237 = 3.220 Adding the computed value for each cell gives the chi-square test statistic χ2: χ2 = 0.222 + 0.237 + · · · + 3.220 = 6.120 Just like before, this test statistic follows a chi-square distribution. However, the degrees of freedom is computed a little differently for a two-way table.38 For two way tables, the degrees of freedom is equal to df = (number of rows - 1) × (number of columns - 1) In our example, the degrees of freedom is df = (2 − 1) × (3 − 1) =
|
2 If the null hypothesis is true (i.e. the algorithms are equally useful), then the test statistic χ2 = 6.12 closely follows a chi-square distribution with 2 degrees of freedom. Using this information, we can compute the p-value for the test, which is depicted in Figure 6.13. COMPUTING DEGREES OF FREEDOM FOR A TWO-WAY TABLE When using the chi-square test to a two-way table, we use df = (R − 1) × (C − 1) where R is the number of rows in the table and C is the number of columns. USE TWO-PROPORTION METHODS FOR 2-BY-2 CONTINGENCY TABLES When analyzing 2-by-2 contingency tables, use the two-proportion methods introduced in Section 6.2. 38Recall: in the one-way table, the degrees of freedom was the number of groups minus 1. 344 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA Figure 6.13: Computing the p-value for the Google hypothesis test. CONDITIONS FOR THE CHI-SQUARE TEST FOR HOMOGENEITY There are two conditions that must be checked before performing a chi-square test for homogeneity. If these conditions are not met, this test should not be used. Independence. Data should be come from multiple independent random samples or from a randomized experiment with multiple treatments. Data can then be organized into a twoway table. When sampling without replacement, the sample size should be less than 10% of the population size for each sample. Large expected counts. All of the cells in the two-way table must have at least 5 expected cases under the assumption that the null hypothesis is true. EXAMPLE 6.45 Compute the p-value and draw a conclusion about whether the search algorithms have different performances. Here, found that the degrees of freedom for this 3 × 2 table is 2. The p-value corresponds to the area under the chi-square curve with 2 degrees of freedom to the right of χ2 = 6.120. Using a calculator, we find that the p-value = 0.047. Using an α = 0.05 significance level, we reject H0. That is, the data provide convincing evidence that there is some difference in performance among the algorithms. Notice that the conclusion of the test
|
is that there is some difference in performance among the algorithms. This chi-square test does not tell us which algorithm performed better than the others. To answer this question, we could compare the relevant proportions or construct bar graphs. The proportion that resulted in the new search can be calculated as current: 1489 5000 = 0.298 test 1: 751 2500 = 0.300 test 2: 682 2500 = 0.136. This suggests that the test 2 algorithm performed better than the current algorithm and test 1 algorithm, because it led to fewer new searches; however, to formally test this specific claim we would need to use a test that includes a multiple comparisons correction, which is beyond the scope of this textbook. A careful reader may have noticed that when there are exactly 2 random samples or treatments and the counts can be arranged in a 2 × 2 table, both a chi-square test for homogeneity and a 2-proportion Z-test could apply. In this case, the chi-square test for homogeneity and the two-sided 2-proportion Z-test are equivalent, meaning that they produce the same p-value.39 39Sometimes the success-failure condition for the Z-test is weakened to require the number of successes and failures to be at least 5, making it consistent with the chi-square condition that expected counts must at least 5. 051015 6.4. HOMOGENEITY AND INDEPENDENCE IN TWO-WAY TABLES 345 χ2χ2χ2 TEST FOR HOMOGENEITY When there are multiple samples or treatments and we are comparing the distribution of a categorical variable across several groups, e.g. comparing the distribution of rural/urban/suburban dwellers among 4 states, Identify: Identify the hypotheses and the significance level, α. H0: The distribution of [...] is the same for each population/treatment. HA: The distribution of [...] is not the same for each population/treatment. Choose: Choose the correct test procedure and identify it by name. Here we use a χ2χ2χ2 test for homogeneity. Check: Check that the test statistic follows a chi-square distribution. 1. Independence: Data come from multiple random samples or from a randomized experiment with multiple treatments. When sampling without replacement, the sample size should be less than 10% of the population size for each sample. 2. Ex
|
pected counts: All expected counts are ≥ 5 (calculate and record expected counts). Calculate: Calculate the χ2-statistic, df, and p-value. test statistic: χ2 = (observed − expected)2 expected df = (# of rows − 1) × (# of columns − 1) p-value = (area to the right of χ2-statistic with the appropriate df ) Conclude: Compare the p-value to α, and draw a conclusion in context. If the p-value is < α, reject H0; there is sufficient evidence that [HA in context]. If the p-value is > α, do not reject H0; there is not sufficient evidence that [HA in context]. 346 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA EXAMPLE 6.46 In an experiment, each individual was asked to be a seller of an iPod (a product commonly used to store music on before smart phones). The participant received $10 + 5% of the sale price for participating. The iPod they were selling had frozen twice in the past inexplicitly but otherwise worked fine. Unbeknownst to the participants who were the sellers in the study, the buyers were collaborating with the researchers to evaluate the influence of different questions on the likelihood of getting the sellers to disclose the past issues with the iPod. The scripted buyers started with “Okay, I guess I’m supposed to go first. So you’ve had the iPod for 2 years...” and ended with one of three questions: • General: What can you tell me about it? • Positive Assumption: It doesn’t have any problems, does it? • Negative Assumption: What problems does it have? The outcome variable is whether the participant discloses or hides the problem with the iPod. Question Type General Positive Assump. Negative Assump. Response Disclose Hide Total 2 71 73 23 50 73 36 37 73 Does the phrasing of the question affect how likely individuals are to disclose the problems with the iPod? Carry out an appropriate test at the 0.05 significance level. Identify: We will test the following hypotheses at the α = 0.05 significance level. H0: The likelihood of disclosing the problem is the same
|
for each question type. HA: The likelihood of disclosing the problem is not the same for each question type. Choose: We want to know if the distribution of disclose/hide is the same for each of the three question types, so we want a chi-square test for homogeneity. Check: This is an experiment in which there were three randomly allocated treatments. Here a treatment corresponds to a question type. All values in the table of expected counts are ≥ 5. Table of expected counts: Question Type General Positive Assump. Negative Assump. Response Disclose Hide 20.3 52.7 20.3 52.7 20.3 52.7 Calculate: Using technology, we get χ2 = 40.1 df = (# of rows − 1) × (# of columns − 1) = 2 × 1 = 2 The p-value is the area under the chi-square curve with 2 degrees of freedom to the right of χ2 = 40.1. Thus, the p-value is almost 0. Conclude: Because the p-value ≈ 0 < α, we reject H0. We have strong evidence that the likelihood of disclosing the problem is not the same for each question type. GUIDED PRACTICE 6.47 If an error was made in the test in the previous example, would it have been a Type I error or a Type II error?40 40In this test, the p-value was less than α, so we rejected H0. If H0 is in fact true, and we reject it, that would be committing a Type I error. We could not have made a Type II error, because a Type II error involves not rejecting H0. 6.4. HOMOGENEITY AND INDEPENDENCE IN TWO-WAY TABLES 347 6.4.4 The chi-square test for independence in two-way tables Often, instead of having separate random samples or treatments, we have just one sample and we want to look at the association between two variables. When these two variables are categorical, we can arrange the responses in a two-way table. In Chapter 3 we looked at independence in the context of probability. Here we look at independence in the context of inference. We want to know if any observed association is due to random chance or if there is evidence of a real association in the population that the sample was taken from. To answer this, we use a chi-square test for independence. The chi-square test for independence
|
applies when there is only one random sample and there are two categorical variables. The null claim is always that the two variables are independent, while the alternate claim is that the variables are dependent. EXAMPLE 6.48 Figure 6.14 summarizes the results of a Pew Research poll. A random sample of adults in the U.S. was taken, and each was asked whether they approved or disapproved of the job being done by President Obama, Democrats in Congress, and Republicans in Congress. The results are shown in Figure 6.14. We would like to determine if the three groups and the approval ratings are associated. What are appropriate hypotheses for such a test? H0: The group and their ratings are independent. (There is no difference in approval ratings between the three groups.) HA: The group and their ratings are dependent. (There is some difference in approval ratings between the three groups, e.g. perhaps Obama’s approval differs from Democrats in Congress.) Obama Democrats Republicans Congress Approve Disapprove Total 842 616 1458 736 646 1382 541 842 1383 Total 2119 2104 4223 Figure 6.14: Pew Research poll results of a March 2012 poll. CONDITIONS FOR THE CHI-SQUARE TEST FOR INDEPENDENCE There are two conditions that must be checked before performing a chi-square test for independence. If these conditions are not met, this test should not be used. Independence. The data must be arrived at by taking one random sample. When sampling without replacement from a finite population, the sample size should be less than 10% of the population size. After the data is collected, it is separated and categorized according to two variables and can be organized into a two-way table. Large expected counts. All of the cells in the two-way table must have at least 5 expected cases assuming the null hypothesis is true. 348 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA EXAMPLE 6.49 First, we observe that the data came from a random sample of adults in the U.S. and that the population size for adults in the U.S. is much larger than 10 times the sample size. Next, let’s compute the expected values that correspond to Figure 6.14, if the null hypothesis is true, that is, if group and rating are independent. The expected count for row one,
|
column one is found by multiplying the row one total (2119) and column one total (1458), then dividing by the table total (4223): 2119×1458 = 731.6. Similarly for the first column and the second row: 2104×1458 4223 = 726.4. Repeating this process, we get the expected counts: 4223 Approve Disapprove Obama Congr. Dem. Congr. Rep. 731.6 726.4 694.0 689.0 693.5 688.5 The table above gives us the number we would expect for each of the six combinations if group and rating were really independent. Because all of the expected counts are at least 5 and there is one random sample, we can carry out the chi-square test for independence. The chi-square test for independence and the chi-square test for homogeneity both involve counts in a two-way table. The chi-square statistic and the degrees of freedom are calculated in the same way. EXAMPLE 6.50 Calculate the chi-square statistic. We calculate (obs−exp)2 chi-square test statistic. exp for each of the six cells in the table. Adding the results of each cell gives the χ2 = (obs − exp)2 exp = (842 − 731.6)2 731.6 =16.7 + · · · = 106.4 + · · · EXAMPLE 6.51 Find the p-value for the test and state the appropriate conclusion. We must first find the degrees of freedom for this chi-square test. Because there are 2 rows and 3 columns, the degrees of freedom is df = (2 − 1) × (3 − 1) = 2. We find the area to the right of χ2 = 106.4 under the chi-square curve with df = 2. The p-value is extremely small, much less than 0.01, so we reject H0. We have evidence that the three groups and their approval ratings are dependent. 6.4. HOMOGENEITY AND INDEPENDENCE IN TWO-WAY TABLES 349 χ2χ2χ2 TEST FOR INDEPENDENCE When there is one sample and we are looking for association or dependence between two categorical variables, e.g. testing for an association between gender and
|
political party, Identify: Identify the hypotheses and the significance level, α. H0: [variable 1] and [variable 2] are independent. HA: [variable 1] and [variable 2] are dependent. Choose: Choose the correct test procedure and identify it by name. Here we use a χ2χ2χ2 test for independence. Check: Check that the test statistic follows a chi-square distribution. 1. Independence: Data come from one random sample. If sampling without replacement, check that the sample size is less than 10% of the population size. 2. Expected counts: All expected counts are ≥ 5 (calculate and record expected counts). Calculate: Calculate the χ2-statistic, df, and p-value. test statistic: χ2 = (observed − expected)2 expected df = (# of rows − 1) × (# of columns − 1) p-value = (area to the right of χ2-statistic with the appropriate df ) Conclude: Compare the p-value to α, and draw a conclusion in context. If the p-value is < α, reject H0; there is sufficient evidence that [HA in context]. If the p-value is > α, do not reject H0; there is not sufficient evidence that [HA in context]. 350 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA EXAMPLE 6.52 A 2021 Pew Research poll asked a random sample of U.S. residents their generation and whether they have personally taken action to help address climate change within the last year. The data are shown below. Response Gen Z Generation Millenial Gen X Boomer & older Total Took action Didn’t take action Total 912 3,160 3,518 6,074 13,664 620 2,275 2,709 4,798 10,402 292 885 809 1,276 3,262 We can see that the percent in the sample from each generation that took action vary: 32% for Gen Z, 28% for Millenial, 23% for Gen X, and 21% for Boomer & older. However, could this be due to random variation based on who happened to end up in the sample? Carry out an appropriate test at the 0.05 significance level to see if there is an association between generation
|
and taking action to help address climate change. Identify: We will test the following hypotheses at the α = 0.05 significance level. H0: Generation and taking action to help address climate change are independent. HA: Generation and taking action to help address climate change are dependent. Choose: Two variables were recorded on the respondents: generation and whether or not they have taken action to help address climate change within the last year. We want to know if these variables are associated / dependent, so we will carry out a chi-square test for independence. Check: According to the problem, there was one random sample taken. We note that the population of U.S. residents is much larger than 10 times the sample size of 13,664. Also, all values in the table of expected counts are ≥ 5. Table of expected counts: Gen Z Generation Millenial Gen X Boomer & older Response Took action Didn’t take action 217.72 754.39 839.85 1450.00 694.28 2405.60 2678.10 4624.00 Calculate: Using technology, we get χ2 = 91.9. The degrees of freedom for this test is given by: df = (# of rows − 1) × (# of columns − 1) = 3 × 1 = 3. The p-value is the area under the chi-square curve with 3 degrees of freedom to the right of χ2 = 91.9. Thus, the p-value = 8.46x10−20 ≈ 0. Conclude: Because the p-value ≈ 0 < α, we reject H0. We have sufficient evidence that generation and taking action to help address climate change are dependent. GUIDED PRACTICE 6.53 In context, interpret the p-value of the test in the previous example.41 41The p-value in this test corresponds to the area to the right of χ2 = 91.9 under the chi-square curve with 3 degrees of freedom. Assuming the probability model is true and assuming the null hypothesis is true, i.e. that generation and response really are independent, there is close to a 0% probability of getting a χ2-statistic as large or larger than 91.9. Equivalently, it is the probability of our observed counts being this different from the expected counts, relative to the expected counts, if the
|
null is true and the model holds. Because the p-value is so small, we reject the null hypothesis. 6.4. HOMOGENEITY AND INDEPENDENCE IN TWO-WAY TABLES 351 6.4.5 Technology: the chi-square test for two-way tables TI-83/84: ENTERING DATA INTO A TWO-WAY TABLE 1. Hit 2ND x−1 (i.e. MATRIX). 2. Right arrow to EDIT. 3. Hit 1 or ENTER to select matrix A. 4. Enter the dimensions by typing #rows, ENTER, #columns, ENTER. 5. Enter the data from the two-way table. TI-83/84: CHI-SQUARE TEST FOR HOMOGENEITY AND INDEPENDENCE Use STAT, TESTS, χ2-Test. 1. First enter two-way table data as described in the previous box. 2. Choose STAT. 3. Right arrow to TESTS. 4. Down arrow and choose C:χ2-Test. 5. Down arrow, choose Calculate, and hit ENTER, which returns χ2 p df chi-square test statistic p-value degrees of freedom TI-83/84: CHI-SQUARE TEST FOR HOMOGENEITY AND INDEPENDENCE TI-83/84: Finding the expected counts 1. First enter two-way table data as described previously. 2. Carry out the chi-square test for homogeneity or independence as described in previous box. 3. Hit 2ND x−1 (i.e. MATRIX). 4. Right arrow to EDIT. 5. Hit 2 to see matrix B. This matrix contains the expected counts. 352 CHAPTER 6. INFERENCE FOR CATEGORICAL DATA CASIO FX-9750GII: CHI-SQUARE TEST FOR HOMOGENEITY AND INDEPENDENCE 1. Navigate to STAT (MENU button, then hit the 2 button or select STAT). 2. Choose the TEST option (F3 button). 3. Choose the CHI option (F3 button). 4. Choose the 2WAY option (F2 button). 5. Enter the data into a matrix: • Hit MAT (F2 button). • Navigate to a matrix you would like to use (e.g. Mat C) and hit EXE. • Specify the matrix dimensions: m is for rows,
|
n is for columns. • Enter the data. • Return to the test page by hitting EXIT twice. 6. Enter the Observed matrix that was used by hitting MAT (F1 button) and the matrix letter (e.g. C). 7. Enter the Expected matrix where the expected values will be stored (e.g. D). 8. Hit the EXE button, which returns χ2 p df chi-square test statistic p-value degrees of freedom 9. To see the expected values of the matrix, go to MAT (F6 button) and select the corre- sponding matrix. GUIDED PRACTICE 6.54 The table from Figure 6.14 is reproduced below. Use a calculator to find the expected values and the χ2-statistic, df, and p-value for the chi-square test for independence.42 Obama Democrats Republicans Congress Approve Disapprove Total 842 616 1458 736 646 1382 541 842 1383 Total 2119 2104 4223 42First create a 2 × 3 matrix with the data. The final summaries should be χ2 = 106.4, p-value is p = 8.06 × 10−24 ≈ 0, and df = 2. Below is the matrix of expected values: Approve Disapprove Obama Congr. Dem. Congr. Rep. 731.59 726.41 693.45 688.55 693.96 689.04 6.4. HOMOGENEITY AND INDEPENDENCE IN TWO-WAY TABLES 353 Section summary • When there are two categorical variables, rather than one, the data can be arranged in a two-way table. • When working with a two-way table, the expected count for each row,column combination is calculated as: expected count = (row total)×(column total). table total • When categorical data are arranged in a two way table, use the χ2 test for homogeneity or the χ2 test for independence. These tests are almost identical; the differences lie in the data collection method and in the hypotheses. • When there are multiple random samples or treatments and we are comparing the distribution of a categorical variable across several groups, e.g. comparing the distribution of rural/urban/suburban dwellers among 4 states, the hypotheses can be written as follows:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.