class: center, middle, inverse, title-slide # ECON 3818 ## Chapter 17 ### Kyle Butts ### 11 October 2021 --- class: clear, middle <!-- Custom css --> <style type="text/css"> /* ------------------------------------------------------- * * !! This file was generated by xaringanthemer !! * * Changes made to this file directly will be overwritten * if you used xaringanthemer in your xaringan slides Rmd * ------------------------------------------------------- */ @import url(https://fonts.googleapis.com/css?family=Roboto&display=swap); @import url(https://fonts.googleapis.com/css?family=Roboto&display=swap); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700&display=swap); @import url(https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible&display=swap); :root { /* Fonts */ --text-font-family: 'Atkinson Hyperelegible'; --text-font-is-google: 1; --text-font-family-fallback: Roboto, -apple-system, BlinkMacSystemFont, avenir next, avenir, helvetica neue, helvetica, Ubuntu, roboto, noto, segoe ui, arial; --text-font-base: sans-serif; --header-font-family: 'Atkinson Hyperelegible' --header-font-is-google: 1; --header-font-family-fallback: Georgia, serif; --code-font-family: 'Source Code Pro'; --code-font-is-google: 1; --base-font-size: 20px; --text-font-size: 1rem; --code-font-size: 0.9rem; --code-inline-font-size: 1em; --header-h1-font-size: 1.75rem; --header-h2-font-size: 1.6rem; --header-h3-font-size: 1.5rem; /* Colors */ --text-color: #131516; --text-color-light: #555F61; --header-color: #FFF; --background-color: #FFF; --link-color: #107895; --code-highlight-color: rgba(255,255,0,0.5); --inverse-text-color: #d6d6d6; --inverse-background-color: #272822; --inverse-header-color: #f3f3f3; --inverse-link-color: #107895; --title-slide-background-color: #272822; --title-slide-text-color: #d6d6d6; --header-background-color: #FFF; --header-background-text-color: #FFF; } html { font-size: var(--base-font-size); } body { font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base); font-weight: normal; color: var(--text-color); } h1, h2, h3 { font-family: var(--header-font-family), var(--header-font-family-fallback); color: var(--text-color-light); } .remark-slide-content { background-color: var(--background-color); font-size: 1rem; padding: 24px 32px 16px 32px; width: 100%; height: 100%; } .remark-slide-content h1 { font-size: var(--header-h1-font-size); } .remark-slide-content h2 { font-size: var(--header-h2-font-size); } .remark-slide-content h3 { font-size: var(--header-h3-font-size); } .remark-code, .remark-inline-code { font-family: var(--code-font-family), Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace; } .remark-code { font-size: var(--code-font-size); } .remark-inline-code { font-size: var(--code-inline-font-size); color: #000; } .remark-slide-number { color: #107895; opacity: 1; font-size: 0.9em; } a, a > code { color: var(--link-color); text-decoration: none; } .footnote { position: absolute; bottom: 60px; padding-right: 6em; font-size: 0.9em; } .remark-code-line-highlighted { background-color: var(--code-highlight-color); } .inverse { background-color: var(--inverse-background-color); color: var(--inverse-text-color); } .inverse h1, .inverse h2, .inverse h3 { color: var(--inverse-header-color); } .inverse a, .inverse a > code { color: var(--inverse-link-color); } img, video, iframe { max-width: 100%; } blockquote { border-left: solid 5px lightgray; padding-left: 1em; } @page { margin: 0; } @media print { .remark-slide-scaler { width: 100% !important; height: 100% !important; transform: scale(1) !important; top: 0 !important; left: 0 !important; } } /* Modified metropolis */ .clear{ border-top: 0px solid #FAFAFA; } h1 { margin-top: -5px; margin-left: -00px; margin-bottom: 30px; color: var(--text-color-light); font-weight: 200; } h2, h3, h4 { padding-top: -15px; padding-bottom: 00px; color: #1A292C; text-shadow: none; font-weight: 400; text-align: left; margin-left: 00px; margin-bottom: -10px; } .title-slide .inverse .remark-slide-content { background-color: #FAFAFA; } .title-slide { background-color: #FAFAFA; border-top: 80px solid #FAFAFA; } .title-slide h1 { color: var(--text-color); font-size: 40px; text-shadow: none; font-weight: 400; text-align: left; margin-left: 15px; } .title-slide h2 { margin-top: -15px; color: var(--link-color); text-shadow: none; font-weight: 300; font-size: 35px; text-align: left; margin-left: 15px; } .title-slide h3 { color: var(--text-color-light); text-shadow: none; font-weight: 300; font-size: 25px; text-align: left; margin-left: 15px; margin-bottom: 0px; } .title-slide h3:last-of-type { font-style: italic; font-size: 1rem; } /* Remove orange line */ hr, .title-slide h2::after, .mline h1::after { content: ''; display: block; border: none; background-color: #e5e5e5; color: #e5e5e5; height: 1px; } hr, .mline h1::after { margin: 1em 15px 0 15px; } .title-slide h2::after { margin: 10px 15px 35px 0; } .mline h1::after { margin: 10px 15px 0 15px; } /* turns off slide numbers for title page: https://github.com/gnab/remark/issues/298 */ .title-slide .remark-slide-number { display: none; } /* Custom CSS */ /* More line spacing */ body { line-height: 1.5; } /* Font styling */ .hi { font-weight: 600; } .mono { font-family: monospace; } .ul { text-decoration: underline; } .ol { text-decoration: overline; } .st { text-decoration: line-through; } .bf { font-weight: bold; } .it { font-style: italic; } /* Font Sizes */ .bigger { font-size: 125%; } .huge{ font-size: 150%; } .small { font-size: 95%; } .smaller { font-size: 85%; } .smallest { font-size: 75%; } .tiny { font-size: 50%; } /* Remark customization */ .clear .remark-slide-number { display: none; } .inverse .remark-slide-number { display: none; } .remark-code-line-highlighted { background-color: rgba(249, 39, 114, 0.5); } /* Xaringan tweeks */ .inverse { background-color: #23373B; text-shadow: 0 0 20px #333; /* text-shadow: none; */ } .title-slide { background-color: #ffffff; border-top: 80px solid #ffffff; } .footnote { bottom: 1em; font-size: 80%; color: #7f7f7f; } /* Lists */ li { margin-top: 4px; } /* Mono-spaced font, smaller */ .mono-small { font-family: monospace; font-size: 16px; } .mono-small .mjx-chtml { font-size: 103% !important; } .pseudocode, .pseudocode-small { font-family: monospace; background: #f8f8f8; border-radius: 3px; padding: 10px; padding-top: 0px; padding-bottom: 0px; } .pseudocode-small { font-size: 16px; } .remark-code { font-size: 68%; } .remark-inline-code { background: #F5F5F5; /* lighter */ /* background: #e7e8e2; /* darker */ border-radius: 3px; padding: 4px; } /* Super and Subscripts */ .super{ vertical-align: super; font-size: 70%; line-height: 1%; } .sub{ vertical-align: sub; font-size: 70%; line-height: 1%; } /* Subheader */ .subheader{ font-weight: 100; font-style: italic; display: block; margin-top: -25px; margin-bottom: 25px; } /* 2/3 left; 1/3 right */ .more-left { float: left; width: 63%; } .less-right { float: right; width: 31%; } .more-right ~ * { clear: both; } /* 9/10 left; 1/10 right */ .left90 { padding-top: 0.7em; float: left; width: 85%; } .right10 { padding-top: 0.7em; float: right; width: 9%; } /* 95% left; 5% right */ .left95 { padding-top: 0.7em; float: left; width: 91%; } .right05 { padding-top: 0.7em; float: right; width: 5%; } .left5 { padding-top: 0.7em; margin-left: 0em; margin-right: -0.4em; float: left; width: 7%; } .left10 { padding-top: 0.7em; margin-left: -0.2em; margin-right: -0.5em; float: left; width: 10%; } .left30 { padding-top: 0.7em; float: left; width: 30%; } .right30 { padding-top: 0.7em; float: right; width: 30%; } .thin-left { padding-top: 0.7em; margin-left: -1em; margin-right: -0.5em; float: left; width: 27.5%; } /* Example */ .ex { font-weight: 300; color: #555F61 !important; font-style: italic; } .col-left { float: left; width: 47%; margin-top: -1em; } .col-right { float: right; width: 47%; margin-top: -1em; } .clear-up { clear: both; margin-top: -1em; } /* Format tables */ table { color: #000000; font-size: 14pt; line-height: 100%; border-top: 1px solid #ffffff !important; border-bottom: 1px solid #ffffff !important; } th, td { background-color: #ffffff; } table th { font-weight: 400; } /* Attention */ .attn { font-weight: 500; color: #e64173 !important; font-family: 'Zilla Slab' !important; } /* Note */ .note { font-weight: 300; font-style: italic; color: #314f4f !important; /* color: #cccccc !important; */ font-family: 'Zilla Slab' !important; } /* Question and answer */ .qa { font-weight: 500; /* color: #314f4f !important; */ color: #e64173 !important; font-family: 'Zilla Slab' !important; } /* Figure Caption */ .caption { font-size: 0.8888889em; line-height: 1.5; margin-top: 1em; color: #6b7280; } </style> <!-- From xaringancolor --> <div style = "position:fixed; visibility: hidden"> $$ \require{color} \definecolor{purple}{rgb}{0.337254901960784, 0.00392156862745098, 0.643137254901961} \definecolor{navy}{rgb}{0.0509803921568627, 0.23921568627451, 0.337254901960784} \definecolor{ruby}{rgb}{0.603921568627451, 0.145098039215686, 0.0823529411764706} \definecolor{alice}{rgb}{0.0627450980392157, 0.470588235294118, 0.584313725490196} \definecolor{daisy}{rgb}{0.92156862745098, 0.788235294117647, 0.266666666666667} \definecolor{coral}{rgb}{0.949019607843137, 0.427450980392157, 0.129411764705882} \definecolor{kelly}{rgb}{0.509803921568627, 0.576470588235294, 0.337254901960784} \definecolor{jet}{rgb}{0.0745098039215686, 0.0823529411764706, 0.0862745098039216} \definecolor{asher}{rgb}{0.333333333333333, 0.372549019607843, 0.380392156862745} \definecolor{slate}{rgb}{0.192156862745098, 0.309803921568627, 0.309803921568627} \definecolor{cranberry}{rgb}{0.901960784313726, 0.254901960784314, 0.450980392156863} $$ </div> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { Macros: { purple: ["{\\color{purple}{#1}}", 1], navy: ["{\\color{navy}{#1}}", 1], ruby: ["{\\color{ruby}{#1}}", 1], alice: ["{\\color{alice}{#1}}", 1], daisy: ["{\\color{daisy}{#1}}", 1], coral: ["{\\color{coral}{#1}}", 1], kelly: ["{\\color{kelly}{#1}}", 1], jet: ["{\\color{jet}{#1}}", 1], asher: ["{\\color{asher}{#1}}", 1], slate: ["{\\color{slate}{#1}}", 1], cranberry: ["{\\color{cranberry}{#1}}", 1] }, loader: {load: ['[tex]/color']}, tex: {packages: {'[+]': ['color']}} } }); </script> <style> .purple {color: #5601A4;} .navy {color: #0D3D56;} .ruby {color: #9A2515;} .alice {color: #107895;} .daisy {color: #EBC944;} .coral {color: #F26D21;} .kelly {color: #829356;} .jet {color: #131516;} .asher {color: #555F61;} .slate {color: #314F4F;} .cranberry {color: #E64173;} </style> ## Chapter 17: Tests for Significance --- # Outline Things to cover in Chapter 17: - Reason we test for significance - Stating a hypothesis - p-value and statistical significance - Tests for a population mean --- # Statistical Inference Two most common types of statistical inference: .hi[Confidence interval] - when the goal is to estimate a population parameter .hi[Tests of significance] - asses the evidence provided by data about a claim concerning the population --- # Tests of Significance .hi.coral[Statistical Test]: Formal procedure for comparing observed data with a claim (hypothesis) whose truth we want to assess Basic idea: an outcome that would rarely happen if a certain claim is true, is good evidence that that claim is not true - .ex[Example:] say someone claims that the average points scored by a team in the NBA over the season is `\(50\)` points. If the 2020 season has a sample mean of `\(80\)` points scored, that's pretty good evidence against the claim. --- # Example Suppose that the return on Spotify stock is normally distributed with an unknown mean and a variance `\(\sigma^2=1\)`. You measure gains and losses for 10 trading days and collect the following sample: `$$1.6, 0.4, -2.5, 1.5, -1.1, 1.3, -0.1, -0.3, 1.2$$` <br/> The average rate of return is `\(\bar{X}=0.3\)`, but there are quite a few days with losses. --- # Example In hypothesis testing, we proceed under the assumption our claim is true and then try to disprove it. For example we could claim `\(\alice{\mu=0}\)`, that is the average Spotify return is 0%. Since the data are drawn from a normal distribution, the sample mean is distributed `\(\bar{X} \sim N(\alice{0}, \frac{1}{10})\)`. --- # Example In hypothesis testing, we proceed under the assumption our claim is true and then try to disprove it. For example we could claim `\(\alice{\mu=0}\)`, that is the average Spotify return is 0%. Since the data are drawn from a normal distribution, the sample mean is distributed `\(\bar{X} \sim N(\alice{0}, \frac{1}{10})\)`. <br/> <center> <div class="hi">Important:</div> Note that we take the hypothesis that \(\alice{\mu = 0}\) as true!! </center> <br/> Now we can use the sampling distribution to comment on how unlikely this claim is. --- # Example <img src="ch17_files/figure-html/unnamed-chunk-1-1.svg" width="90%" style="display: block; margin: auto;" /> --- # Stating a Hypothesis It is very important to state the hypothesis clearly. A hypothesis has two parts: .hi.alice[Null hypothesis], denoted `\(\alice{H_0}\)`, is the claim we are trying to disprove - test is designed to test the strength of evidence against the null hypothesis .hi.ruby[Alternative hypothesis], denoted `\(\ruby{H_1}\)`, is the claim we are trying to find evidence for.sup[*] - antithesis of the null .footnote[.sup[*] Note that we are .hi[NOT] trying to prove the alternative hyptothesis is correct] --- # Alternative Hypothesis There are two types of alternative hypotheses: One-sided alternative - states the true parameter is larger *or* smaller (not both) Two-sided alternative - states the true parameter is *different* from the null --- # Example Back to the Spotify example: Lets say we're claiming there is no return on average. We would like to see if we can disprove this hypothesis in favor of a claim that there is a positive return `$$\alice{H_0}: \mu=0$$` `$$\ruby{H_1}: \mu > 0$$` .ex[Clicker Question:] What type of hypothesis test is this? <ol type = "a"> <li>alternative</li> <li>null</li> <li>one-sided</li> <li>two-sided</li> </ol> --- # Continuing Example So in the Spotify example, we had 10 observations with a sample mean, `\(\bar{X}=0.3\)`. We also somehow know that `\(\sigma^2 = 1\)`. If we want to test the hypothesis `$$\alice{H_0}: \mu=0$$` `$$\ruby{H_1}: \mu > 0$$` <br> We want to calculate the probability we got an `\(\bar{X}\)` as extreme as 0.3 if the true population `\(\mu=0\)`. Is it rare that we got 0.3 or is that quite common from the sampling distribution? This means we want to calculate `\(P(\bar{X}>0.3)\)` if `\(\bar{X} \sim N(0,\frac{1}{10})\)`. We will write that as: $$ P(\bar{X} > 0.3 \ \vert\ \mu = 0) $$ --- class: clear, middle <img src="ch17_files/figure-html/p-value-1.svg" style="display: block; margin: auto;" /> --- # Continuing Example We want to calculate `\(P(\bar{X}>0.3)\)` if `\(\bar{X} \sim N(0,\frac{1}{10})\)` -- `$$P(\bar{X}>0.3) = P(\frac{\bar{X}-\mu}{\sigma/\sqrt{n}} > \frac{0.3- \alice{0}}{1/\sqrt{10}}) = P(Z>0.95) = 0.1711$$` This says that if the *true* population mean is `\(\alice{\mu = 0}\)`, then 17% of the time we would expect to see a sample mean greater than 0.3, 17% of the time. - This is not so rare (~ 1 out of 5), so this isn't strong evidence against the null. - It doesn't prove it, but it does not rule it out. --- # p-values Suppose you calculate a test statistic `\(\hat{\theta}\)` (e.g. mean or standard deviation) from sample data, and formulate a null hypothesis `\(\alice{H_0}: \theta=\theta_0\)` about the true value of `\(\theta\)` - .hi.kelly[p-value] is the probability that the test statistic takes a value as or *more extreme* than the observed value `\(\hat{\theta}\)`, <span class="hi">under the assumption that</span> `\(\alice{H_0}\)` <span class="hi">is true</span><span class="sup">*</span> <div class="footnote"> <span class="sup">*</span> Can not emphasize this enough. Under the assumption that \(\alice{H_0}\) is true. </div> -- Typically, the test statistic we calculate is `\(\bar{X}\)` and formulate a hypothesis about `\(\mu\)` - In this context, the p-value is the probability of getting an `\(\bar{X}\)` as or *more extreme*, if the true population mean is equal to `\(\mu\)` --- # Calculating p-values The way a p-value is calculated changes depending on the type of alternative hypothesis we have: `$$\alice{H_0: \mu = \mu_0}$$` **Left-tailed Test:** `$$\ruby{H_1}: \mu> \mu_0 \ \implies p = P(\bar{X} \leq \bar{X}_{obs} \ \big\vert \ \alice{\mu = \mu_0})$$` -- **Right-tailed Test:** `$$\ruby{H_1}: \mu< \mu_0 \ \implies p = P(\bar{X} \geq \bar{X}_{obs} \ \big\vert \ \alice{\mu = \mu_0})$$` -- **Two-tailed Test:** `$$\ruby{H_1}: \mu \neq \mu_0 \ \implies p = 2 \cdot P(\bar{X} \geq \vert\bar{X}_{obs} \vert \ \big\vert \ \alice{\mu = \mu_0})$$` where `\(\bar{X}\)` is a random draw from our sample distribution and `\(\bar{X}_{obs}\)` is our **observed** value for the sample statistic. --- # Example -- One-sided Lets say we have a sample of 30 observations and calculate a sample mean of 1020. We also know that the standard deviation is `\(\sigma=40\)`. We want to test the following hypothesis: `$$\alice{H_0}: \mu=1000$$` `$$\ruby{H_1}: \mu > 1000$$` - Write out p-value: -- `$$p = P(\bar{X} \geq 1020 \ \big| \ \mu=1000)$$` - Solve for p-value: -- `$$P(\frac{\bar{X}-\mu_0}{\sigma/\sqrt{n}}\geq \frac{1020-1000}{40/\sqrt{30}} )= P(Z>2.74)=0.0032$$` So `\(p=0.003\)`, the probability we get a sample mean as large as 1020 if the true mean is 1000 is .3%, super rare! --- # Example -- Two-sided Say we have nine observations, and calculate a sample mean of `\(\bar{X} = 0.5\)`. We know the underlying distribution has a standard deviation `\(\sigma = 1\)`. We want to test the following hypothesis: `$$\alice{H_0}: \mu=0$$` `$$\ruby{H_1}: \mu \neq 0$$` - Write out p-value: -- `$$p=2 \cdot P(\bar{X} \geq 0.5 \ \big| \ \mu=0)$$` - Solve for p-value: -- `$$2 \cdot P(\frac{\bar{X}-\mu_0}{\sigma/\sqrt{n}}\geq \frac{0.5-0}{1/\sqrt{9}} )=2 \cdot P(Z>1.5)=2\cdot(0.067)=0.134$$` So `\(p=0.134\)`, meaning there is a 13.4% probability of getting a sample mean *as extreme as* 0.5 if the true mean is 0. --- # Breakout Group Say we have a sample of 25 observations and we calculate a sample mean of 11,500. We know that the standard deviation is `\(\sigma=5000\)`. We want to test the following hypothesis: `$$\alice{H_0}: \mu=12,675$$` `$$\ruby{H_1}: \mu < 12,675$$` Calculate the p-value: <ol type = "a"> <li>0.407</li> <li>0.814</li> <li>0.119</li> <li>0.238</li> </ol> --- # Breakout Group Say we have a sample of 25 observations and we calculate a sample mean of 11,500. We know that the standard deviation is `\(\sigma=5000\)`. We want to test the following hypothesis: `$$\alice{H_0}: \mu=12,675$$` `$$\ruby{H_1}: \mu < 12,675$$` --- # Hypothesis Testing A restaurant owner is determining whether to expand her restaurant to another location. She counts the number of customers per weekend and calculates an average of 538 customers over 50 weekends. She's heard that restaurants of her size shouldn't expand unless they get more than 510 customers each weekend. Conduct a hypothesis at the `\(\alpha=0.05\)` level and determine whether or not she can feel confident she gets at least 510 customers each weekend. Assume `\(\sigma= 120\)`. - State Null and Alternative hypotheses -- `$$\alice{H_0}: \mu=510$$` `$$\ruby{H_1}: \mu \geq 510$$` --- # Hypothesis Testing A restaurant owner is determining whether to expand her restaurant to another location. She counts the number of customers per weekend and calculates an average of 538 customers over 50 weekends. She's heard that restaurants of her size shouldn't expand unless they get more than 510 customers each weekend. Conduct a hypothesis at the `\(\alpha=0.05\)` level and determine whether or not she can feel confident she gets at least 510 customers each weekend. Assume `\(\sigma= 120\)`. - Calculate p-value -- `\(P(\bar{X} \geq 538 | \mu=510)=0.049\)` If true population mean is 510, there is a 4.95% probability of calculating a sample mean as large as 538 --- # Interpreting p-Values Small p-values are evidence against the null, because they say **the observed value of the sample statistic if very unlikely to occur if the null hypothesis,** `\(\alice{H_0}\)`, **is true.** - Larger p-values fail to give evidence against the null because the observed sample statistic could have resulted by chance if the null hypothesis, `\(\alice{H_0}\)` is true. -- <br/> <center> p-values do not tell you the probability that \(\alice{H_0}\) is true!!<span class="sup">*</span> </center> .footnote[.sup[*] I will likely ask this on the exam, so make sure to understand why] --- # p-Values and Statistical Significance To review, our decision process using p-values is - p-value is sufficiently small `\(\rightarrow\)` reject `\(\alice{H_0} \rightarrow\)` accept `\(\ruby{H_1}\)` - p-value is too large `\(\rightarrow\)` fail to reject `\(\alice{H_0} \rightarrow\)` do not accept `\(\ruby{H_1}\)` We *never* say "accept `\(\alice{H_0}\)`". All we can say is if there is enough evidence to say it is false, we cannot know if it is true. We say our results are .hi.purple[statistically significant] if we reject `\(\alice{H_0}\)`.sup[*] <div class="footnote"> <span class="sup">*<span> This saying is short for "statistically significantly different from zero" (or \(H_0\) more generally). </div> --- # p-Values and Statistical Significance How small does p need to be in order to be "sufficiently small"? When can we claim our results are statistically significant? Suppose you calculate a p-value, and specify a .hi.purple[level of significance], `\(\alpha\)`. We say our results are .hi.purple[statistically significant] if: `$$\text{p-value} \leq \purple{\alpha}$$` We will discuss how to think about choosing `\(\alpha\)`. Some of the most common levels of significance are .01, .05, and 0.1. --- # Group Example A restaurant owner is determining whether to expand her restaurant to another location. She counts the number of customers per weekend and calculates an average of 538 customers over 50 weekends. She's heard that restaurants of her size shouldn't expand unless they get more than 510 customers each weekend. Conduct a hypothesis at the `\(\alpha=0.05\)` level and determine whether or not she can feel confident she gets at least 510 customers each weekend. Assume `\(\sigma= 120\)`. 1. State Null and Alternative hypotheses 2. Calculate p-value 3. Is our estimate statistically siginificant? --- # Group Example 1. State Null and Alternative hypotheses - `\(\alice{H_0}: \mu=510; \quad \ruby{H_1}: \mu \geq 510\)` 2. Calculate p-value - `\(P(\bar{X} \geq | \mu=510)=0.049\)` 3. Is our estimate statistically siginificant? - `\(0.049 < 0.05 \implies p-value<\alpha \implies \text{Reject } \alice{H_0}\)` Reject null hypothesis in favor of alternative, that the true population mean number of customers is greater than 510 --- # Hypothesis Testing Algorithm A hypothesis test consists of 4 parts: - Null hypothesis, `\(\alice{H_0}\)` - Alternative hypothesis, `\(\ruby{H_1}\)` - Test statistic, `\(\hat{\theta}\)`, most commonly `\(\bar{X}\)` - Level of significances `\(\alpha\)` With these, we reach the conclusion: - reject `\(\alice{H_0}\)` if `\(p \leq \alpha\)` - fail to reject `\(\alice{H_0}\)` if `\(p > \alpha\)` --- # Rejection Region Imagine getting many many observed sample means `\((\bar{X}_{1, obs}, \bar{X}_{2, obs}, \dots, \bar{X}_{100, obs})\)`. We don't want to calculate 100 `\(p\)`-values. It would be better if we could figure out for what range of values that would give us `\(p\)`-value less than `\(\alpha\)`. --- # Rejection Region <img src="ch17_files/figure-html/rejection-region-1.svg" width="90%" style="display: block; margin: auto;" /> --- # Rejection Region <img src="ch17_files/figure-html/rejection-region-ex1-1.svg" width="90%" style="display: block; margin: auto;" /> --- # Rejection Region <img src="ch17_files/figure-html/rejection-region-ex2-1.svg" width="90%" style="display: block; margin: auto;" /> --- # Rejection Region We call the range of values for our *observed* test statistic `\(\bar{X}_{obs}\)` which we would reject the null the .hi.purple[rejection region] Calculate rejection region using - the population mean, `\(\mu\)` under the null hypothesis - the standard deviation, `\(\sigma\)` - level of significance, `\(\alpha\)` and Z-score associated with it The rejection region tells us how extreme the sample mean needs to be for us to reject the null hypothesis `\(\alice{H_0}: \mu = \mu_0\)` --- # Calculate Rejection Region -- One-Sided Let's say we want to test a hypothesis about the number of children in a family. We have a sample of 25 observations, and we know `\(\sigma=0.8\)`. We decide to test the following hypothesis: `$$\alice{H_0}:\mu=2$$` `$$\ruby{H_1}:\mu<2$$` If we are testing at the 5% significance level, calculate the rejection region. - The rejection region is the values of `\(\bar{X}\)` that are far enough away from `\(\mu\)` that we would reject `\(\alice{H_0}\)` -- We want to find `\(\bar{X}^*\)` that solves `$$R = P(\bar{X} \leq \bar{X}^* \ \vert \ \mu_0 =2) = 0.05$$` --- # Calculating Rejection Region -- One-Sided `$$P(\bar{X}\leq\bar{X}^* \vert \mu_0 = 2) = 0.05 = P(Z\leq\frac{\bar{X}^*-\mu}{\sigma/\sqrt{n}})$$` Plugging in `\(\mu\)` and `\(\sigma\)`, we have: `$$P(Z\leq\frac{\bar{X}^*-2}{0.8/5})=0.05=P(Z\leq\frac{\bar{X}^*-2}{.16})=0.05$$` -- We know that `\(P(Z \leq -1.645)=0.05\)`, therefore: `$$\frac{\bar{X}^*-2}{0.16}=-1.645 \implies \bar{X}^*=1.74$$` This means our rejection region is all `\(\bar{X}\leq1.74\)`. In words, we will reject `\(\alice{H_0}:\mu=2\)` at the `\(\alpha=0.05\)` level if we calculate a sample mean of 1.74 or smaller. --- # Breakout Group A study is conducted to determine the average income of 18-25 year olds in San Antonio. They are trying to test whether the average is greater than \$21,000. The study is able to collect 16 different salaries. We somehow know that the population standard deviation is `\(\sigma=\)`\$2000. What sample averages would we reject the null hypothesis at the `\(\alpha=0.05\)` level? $$\alice{H_0}: \mu = \$21,000$$ $$\ruby{H_1}: \mu > \$21,000$$ <ol type = "a"> <li> Reject if \( \bar{X} < \$21,822.5 \) </li> <li> Reject if \( \bar{X} > \$21,822.5 \) </li> <li> Reject if \( \bar{X} < \$20,177.5 \) </li> <li> Reject if \( \bar{X} >\$20,177.5 \) </li> </ol> --- # Breakout Group A study is conducted to determine the average income of 18-25 year olds in San Antonio. They are trying to test whether the average is greater than \$21,000. The study is able to collect 16 different salaries. We somehow know that the population standard deviation is `\(\sigma=\)`\$2000. What sample averages would we reject the null hypothesis at the `\(\alpha=0.05\)` level? $$\alice{H_0}: \mu = \$21,000$$ $$\ruby{H_1}: \mu > \$21,000$$ --- # Calculating Rejection Region -- Two-Sided Solving for a rejection region changes a little bit when we consider a two-tailed test. Example: Suppose we have a sample of 25 observations, we know `\(\sigma=3.5\)`. We want to test the following hypothesis at the `\(\alpha=0.05\)` level. `$$\alice{H_0}: \mu=13.5$$` `$$\ruby{H_1}: \mu \neq 13.5$$` Our rejection region is calculated by finding two different `\(\bar{X}^*\)`'s. `$$P(\bar{X}\geq\bar{X}^*_U)=\frac{0.05}{2}$$` `$$P(\bar{X}\leq\bar{X}^*_L)=\frac{0.05}{2}$$` --- # Calculating Rejection Region -- Two-Sided `$$P(\bar{X}\geq\bar{X}^*_U)= \frac{0.05}{2} = 0.025 = P(Z>\frac{\bar{X}^*_U-13.5}{0.64})$$` - We know `\(P(Z>1.96)=0.025\)`. - Therefore: `$$\frac{\bar{X}^*_U-13.5}{0.64}=1.96 \implies \bar{X}^*_U=14.75$$` --- # Breakout Group For the same problem, solve for `\(\bar{X}^*_L\)`. Remember it solves: `\(P(\bar{X}\leq\bar{X}^*_L)=\frac{0.05}{2}\)` <ol type = "a"> <li> -14.75 </li> <li> 12.246 </li> <li> 11.54 </li> </ol> --- # Solving Hypothesis Testing Problem **p-value method** - calculate p-value, varies based off type of alternative hypothesis - p-value: probability of getting as extreme of a sample statistic, if the null hypothesis is true <center> If \(p<\alpha \implies\) reject \( \alice{H_0} \) </center> **Rejection region method** - calculate rejection region based off level of significance - compare sample statistic with rejection region <center> If sample statistic is in rejection region, reject \( \alice{H_0} \) </center>