class: middle background-image: url(data:image/png;base64,#LTU_logo.jpg) background-position: top left background-size: 30% # STM1001 [Topic 6](https://bookdown.org/content/f9d035ed-86ea-4779-ad01-31acc973f0dd/) Workshop ## `\(t\)`-tests for two-sample hypothesis testing ### La Trobe University This workshop complements the [Topic 6 readings](https://bookdown.org/content/f9d035ed-86ea-4779-ad01-31acc973f0dd/) --- # Topic 6: `\(t\)`-tests for two-sample hypothesis testing ## In this week's readings: <iframe src="https://bookdown.org/content/f9d035ed-86ea-4779-ad01-31acc973f0dd/" width="100%" height="400px" data-external="1"></iframe> --- # Today's workshop * We will not have time to cover every concept, so please make sure you read this topic's readings thoroughly. * Today, we will see both the independent samples `\(t\)`-test and the paired `\(t\)`-test in action -- * Note that there are two versions of the independent samples `\(t\)`-test. Deciding which version to use is an important step (see readings for more) -- * For the sake of time today, we will be assuming the assumptions have been met * Therefore it will be important to refer to the readings for additional information regarding checking assumptions, effect sizes, etc. --- name: stat class: middle background-image: url(data:image/png;base64,#slide_1.png) background-size: 110% --- name: stat class: middle background-image: url(data:image/png;base64,#slide_9.png) background-size: 100% --- # Claim * Suppose we made a claim that we believed that on average, people with brown eyes spend either more or less time sleeping than people without brown eyes * We will test this claim using the independent samples `\(t\)`-test * We will use your answers from the following Menti questions to test the claim --- 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 --- # Independent samples `\(t\)`-test * So how do we test the claim? * We will use the ***independent samples `\(t\)`-test*** -- * First, we need to set up our hypotheses: `$$H_0:\mu_1 = \mu_2\;\;\text{versus}\;\;H_1:\mu_1 \neq \mu_2,$$` where: -- * `\(\mu_1\)` denotes the true average number of minutes people with brown eyes spend sleeping per day * `\(\mu_2\)` denotes the true average number of minutes people who do not have brown eyes spend sleeping per day Note: if `\(\mu_1 = \mu_2\)`, this means that the difference between `\(\mu_1\)` and `\(\mu_2\)` is zero. So the above hypothesis could equivalently be written as: `\(H_0:\mu_1 - \mu_2 = 0\;\;\text{versus}\;\;H_1:\mu_1 - \mu_2 \neq 0.\)` --- # Independent samples `\(t\)`-test * What does it mean to have ***two independent groups***, as we need to have to carry out an independent-samples `\(t\)`-test? * One way of thinking of it would be that individuals can only be in one group or the other: not both. -- * E.g. for this example, we assume a person belongs to the 'brown eyes' or 'not brown eyes' group, but not both. * This means the two groups are ***independent***, and appropriate for the independent-samples `\(t\)`-test. --- # Independent samples `\(t\)`-test * What type of variables are required for the independent samples `\(t\)`-test? -- .content-box-blue[ .center[ An independent samples *t*-test will always involve two variables: ] 1. The ***dependent*** variable, sometimes also called the *response* variable. This should be a numeric, continuous variable. 2. The ***independent*** variable. This should be a categorical variable with only ***two categories***. ] -- * So our ***dependent*** variable is minutes of sleep * Our ***independent*** variable is eye colour --- # Independent samples `\(t\)`-test * Let's use our responses to carry out the test `$$H_0:\mu_1 = \mu_2\;\;\text{versus}\;\;H_1:\mu_1 \neq \mu_2,$$` where: * `\(\mu_1\)` denotes the true average number of minutes people with brown eyes spend sleeping per day * `\(\mu_2\)` denotes the true average number of minutes people who do not have brown eyes spend sleeping per day * [*t*-test calculator](https://www.socscistatistics.com/tests/studentttest/default2.aspx ) --- #Group activity 1 * In your group, discuss the result and answer the following: * What is the `\(p\)`-value? * What is the test statistic (*t*-value)? * Do we have evidence that that on average, people with brown eyes spend either more or less time sleeping than people who do not have brown eyes? 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 --- #Independent samples vs. Paired `\(t\)`-test * One key concept to remember for an independent samples `\(t\)`-test is that we must have ***two independent groups*** * This would normally mean that it is not possible for the same person (or subject/observation if the study is not about people) to be in both groups (e.g. brown eyes vs. not brown eyes) -- * On the other hand, a **paired** *t*-test tests for a difference when we have the same set of subjects in each sample * This would mean we have ***two dependent groups*** -- * One way of thinking of it would be that all individuals must be in both groups --- # Claim * Suppose we made a claim that we believed that on average, the average height of current STM1001 students now is different their height from 5 years ago * We will test this claim using the paired `\(t\)`-test * Shortly, we will use your answers from the previous Menti questions to test the claim --- # Paired `\(t\)`-test * So how do we test the claim? * We will use the ***paired `\(t\)`-test*** -- * First, we need to set up our hypotheses: `$$H_0:\mu_D = 0\;\;\text{versus}\;\;H_1:\mu_D \neq 0,$$` where: -- * `\(\mu_D\)` is defined as the true mean difference between heights now and heights 5 years ago --- # Paired `\(t\)`-test * What type of variables are required for the paired `\(t\)`-test? -- .content-box-blue[ .center[ A paired *t*-test will always involve two variables: ] 1. The ***dependent*** variable, sometimes also called the *response* variable. This should be a numeric, continuous variable. 2. The ***independent*** variable. This should be a categorical variable with only ***two categories*** which represent before/after categories, or two different conditions. ] -- * So our ***dependent*** variable is height * Our ***independent*** variable is time (now or 5 years ago) --- # Paired `\(t\)`-test * Let's use our responses to carry out the test `$$H_0:\mu_D = 0\;\;\text{versus}\;\;H_1:\mu_D \neq 0,$$` where: * `\(\mu_D\)` is defined as the true mean difference between heights now and heights 5 years ago * [*t*-test calculator](https://www.socscistatistics.com/tests/ttestdependent/default2.aspx ) --- #Group activity 2 * In your group, discuss the result and answer the following: * What is the `\(p\)`-value? * What is the test statistic (*t*-value)? * Do we have evidence that that on average, the average height of STM1001 students now is different from 5 years ago? What is the p-value? 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/content/f9d035ed-86ea-4779-ad01-31acc973f0dd/) --- 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 6 Readings](https://bookdown.org/content/f9d035ed-86ea-4779-ad01-31acc973f0dd/) --- 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>