class: middle background-image: url(data:image/png;base64,#LTU_logo.jpg) background-position: top left background-size: 30% # STM1001 [Topic 9](https://bookdown.org/a_shaker/STM1001_Topic_9/) Workshop ## Hypothesis Testing for One and Two Sample Proportions ### La Trobe University This workshop complements the [Topic 9 readings](https://bookdown.org/a_shaker/STM1001_Topic_9/) --- # Topic 9: Hypothesis Testing for One and Two Sample Proportions <iframe src="https://bookdown.org/a_shaker/STM1001_Topic_9/" width="100%" height="400px" data-external="1"></iframe> --- # Claim * 60% of university students prefer Android over Apple (iOS) phones * What do you think...? --- name: menti class: middle background-image: url(data:image/png;base64,#menti.jpg) background-size: 115% # Menti ## Go to [www.menti.com](https://www.menti.com) and use ## the code provided --- # One-sample test of proportions * We will use the one-sample test of proportions to test the claim -- * First, we need to set up our hypotheses: `$$H_0 : p = p_0\text{ versus } H_1 : p \neq p_0\text{ (or }p<p_0\text{ or }p>p_0),$$` where: * `\(p_0\)` denotes the population proportion under the null hypothesis. -- What is `\(p_0\)` in our example? --- # One-sample test of proportions * Next, we need to check the assumptions: -- .content-box-blue[ .center[ **One-sample test of proportion condition:** ] `\(np \geq 5\)` and `\(n(1 - p) \geq 5\)`. ] -- * Note that we can use `\(p_0\)` in place of `\(p\)` * `\(n\)` is the number of people in our sample --- # One-sample test of proportions * For the sake of this example, we will carry out the test whether or not the assumptions have been met <iframe width='800' height='440' src='https://rdrr.io/snippets/embed/?code=%23%20Enter%20x%2C%20n%20and%20p0%20into%20the%20code%20below%2C%20where%3A%0A%23%20x%20is%20the%20number%20of%20people%20who%20said%20they%20prefer%20android%0A%23%20n%20is%20the%20number%20of%20people%20who%20answered%20the%20question%0A%23%20p0%20%3D%200.6%0A%0Aprop.test(x%2C%20n%2C%20p0)' frameborder='0'></iframe> --- #Group activity 1 * In your group, discuss the result and answer the following: * What is the sample proportion (i.e., `\(\hat{p}\)`)? * What is the `\(p\)`-value? * What is the 95% confidence interval for `\(p\)`? * Do we have evidence that the percentage of university students who prefer Android over Apple (iOS) phones is different from 60%? After you have had a chance to discuss, nominate one person who can speak for the group and explain your conclusion to the rest of the class --- # Claim * Android vs Apple (iOS) preferences depend on whether or not you have brown eyes * What do you think...? --- # Two-sample test of proportions * We will use the two-sample test of proportions to test the claim -- * We will be comparing the proportions from two different (independent) populations: Brown eyes vs. not brown eyes -- * First, we need to set up our hypotheses: `$$H_0 : p_1 = p_2 \text{ versus } H_1 : p_1 \neq p_2,$$` where: * `\(p_1\)` denotes the population proportion of university students with brown eyes who prefer Android * `\(p_2\)` denotes the population proportion of university students who do not have brown eyes who prefer Android --- # Two-sample test of proportions * Next, we need to check the assumptions: -- .content-box-blue[ .center[ **Two-sample test of proportion conditions:** ] * `\(n_1p_1 \geq 5\)` and `\(n_1(1 - p_1) \geq 5\)` * `\(n_2p_2 \geq 5\)` and `\(n_2(1 - p_2) \geq 5\)`. ] -- * `\(n_1\)` and `\(n_2\)` are the sample sizes of Group 1 and Group 2 respectively * `\(x_1\)` and `\(x_2\)` are the number of people who prefer Android in Group 1 and Group 2 respectively * `\(\hat{p}_1 = \frac{x_1}{n_1} \text{ and } \hat{p}_2 = \frac{x_2}{n_2}.\)` * Note that since we do not know the true values of `\(p_1\)` and `\(p_2\)`, we will instead use `\(\hat{p}_1\)` and `\(\hat{p}_2\)` to check the assumptions --- # Two-sample test of proportions * For the sake of this example, we will carry out the test whether or not the assumptions have been met <iframe width='800' height='440' src='https://rdrr.io/snippets/embed/?code=%23%20Enter%20the%20numbers%20for%20x1%2C%20x2%2C%20n1%20and%20n2%20into%20their%20respective%20positions%0A%0Aprop.test(x%20%3D%20c(x1%2C%20x2)%2C%20n%20%3D%20c(n1%2C%20n2))' frameborder='0'></iframe> --- #Group activity 2 * In your group, discuss the result and answer the following: * What is the sample proportion for each group (i.e., `\(\hat{p_1}\)` and `\(\hat{p_2}\)`)? * What is the `\(p\)`-value? * What is the 95% confidence interval for the difference between `\(p_1\)` and `\(p_2\)`? * Do we have evidence that Android over Apple (iOS) preferences are different between eye colour groups? After you have had a chance to discuss, nominate one person who can speak for the group and explain your conclusion to the rest of the class --- #More details in the readings * For more, see [this topic’s readings](https://bookdown.org/a_shaker/STM1001_Topic_9/) --- background-image: url(data:image/png;base64,#computerlab.jpg) background-position: bottom background-size: 75% class: center # See you in the computer labs! Continue with this topic's readings: [Topic 9 Readings](https://bookdown.org/a_shaker/STM1001_Topic_9/) --- class: middle <font color = "grey"> These notes have been prepared by Amanda Shaker. The copyright for the material in these notes resides with the authors named above, with the Department of Mathematics and Statistics and with La Trobe University. Copyright in this work is vested in La Trobe University including all La Trobe University branding and naming. Unless otherwise stated, material within this work is licensed under a Creative Commons Attribution-Non Commercial-Non Derivatives License <a href = "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank"> BY-NC-ND. </a> </font>