% 260s20Assignment.tex Tests: Part One \documentclass[12pt]{article} %\usepackage{amsbsy} % for \boldsymbol and \pmb %\usepackage{graphicx} % To include pdf files! \usepackage{amsmath} \usepackage{amsbsy} \usepackage{amsfonts} \usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=blue, urlcolor=blue]{hyperref} % For links \usepackage{comment} %\usepackage{fullpage} \oddsidemargin=0in % Good for US Letter paper \evensidemargin=0in \textwidth=6.3in \topmargin=-1in \headheight=0.2in \headsep=0.5in \textheight=9.4in %\pagestyle{empty} % No page numbers \begin{document} %\enlargethispage*{1000 pt} \begin{center} {\Large \textbf{STA 260s20 Assignment Six: Hypothesis Testing Part One}}\footnote{Copyright information is at the end of the last page.} %\vspace{1 mm} \end{center} \noindent Please read Sections 6.3.3-6.3.6 in the text, pages 332-344. Notice how the authors like to go from the testing problem directly to the $p$-value, with the test statistic an intermediate step that is sometimes not even identified as such. Rather than comparing the test statistic to a critical value, they just compare the $p$-value to $\alpha$. Their emphasis on the normal model with known variance (the ``location normal model") is helpful for understanding even though it is never used in practice. The following homework problems are not to be handed in. They are preparation for Quiz 6 (Week of March 2nd) and Term Test 2. \textbf{Please try each question before looking at the solution}. Use the formula sheet. \begin{enumerate} \item On Test Two and the final exam, you may be asked for some well-known distribution facts. You are also responsible for the proofs if requested, but in these questions you just write the answer from memory. You need to have these things in your head in order to put important derivations together. This is largely a repeat from Assignment Four. \begin{enumerate} \item Let $X\sim N(\mu,\sigma^2)$ and $Y=aX+b$, where $a$ and $b$ are constants. What is the distribution of $Y$? \item Let $X\sim N(\mu,\sigma^2)$ and $Z = \frac{X-\mu}{\sigma}$. What is the distribution of $Z$? \item Let $Z \sim N(0,1)$. What is the distribution of $Y=Z^2$? \item Let $X_1, \ldots, X_n$ be a random sample from a $N(\mu,\sigma^2)$ distribution. What is the distribution of $Y = \sum_{i=1}^nX_i$? \item \label{combo} Let $X_1, \ldots, X_n$ be independent random variables, with $X_i \sim N(\mu_i,\sigma_i^2)$. Let $a_1, \ldots, a_n$ be constants. What is the distribution of $Y = \sum_{i=1}^n a_iX_i$? \item Let $X_1, \ldots, X_n$ be a random sample from a $N(\mu,\sigma^2)$ distribution. What is the distribution of the sample mean $\overline{X}_n$? \item Let $X_1, \ldots, X_n$ be a random sample from a $N(\mu,\sigma^2)$ distribution. What is the distribution of $\frac{\sqrt{n}(\overline{X}-\mu)}{\sigma}$? Are you using the Central Limit Theorem? \item Let $X_1, \ldots, X_n$ be a random sample from a $N(\mu,\sigma^2)$ distribution. What is the distribution of $\frac{(n-1)S^2}{\sigma^2}$? \item Let $X_1, \ldots, X_n$ be a random sample from a $N(\mu,\sigma^2)$ distribution. What is the distribution of $\frac{\sqrt{n}(\overline{X}-\mu)}{S}$? \item Let $X_1, \ldots, X_n$ be independent $\chi^2(\nu_i)$ random variables. What is the distribution of $Y = \sum_{i=1}^n X_i$? \end{enumerate} \vspace{30mm} \pagebreak %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \item Vocabulary is important too. You need to know what the words mean in order to understand the lectures in this class and later statistics classes. Questions like these may be on Test Two and the final exam. I am even asking about Type~I and Type~II error; as long as you are memorizing things, you might as well know this arbitrary designation too. Fill in the blanks. \begin{enumerate} \item A collection of independent and identically distributed random variables is called a \underline{\hspace{15mm}}. \item A function of the sample data that is not a function of any unknown parameters is called a \underline{\hspace{15mm}} \item An estimator $T_n$ is said to be \underline{\hspace{15mm}} for $\theta$ if $E(T_n)=\theta$. \item An estimator $T_n$ is said to be \underline{\hspace{15mm}} for $\theta$ if $T_n \stackrel{p}{\rightarrow}\theta$. \item Quantities such as $E(X)$, $Var(X)$, $E(X^k)$, $E(X^2Y^2)$ and so on are called (population) \underline{\hspace{15mm}}. \item The sample moment corresponding to $E(X^4)$ is \underline{\hspace{15mm}}. \item The set of values that can be taken on by a parameter or parameter vector is called the \underline{\hspace{15mm}}. \item The vector of observed data values is a point in the \underline{\hspace{15mm}}. \item A statement like $\theta \in \Omega_0$ is called the \underline{\hspace{15mm}}. \item A statement like $\theta \in \Omega_1$ is called the \underline{\hspace{15mm}}. \item Ideas like that nothing is happening, the treatment had no effect, it makes no difference, no action is required, and so on are expressed by the \underline{\hspace{15mm}}. \item The null hypothesis is rejected when the data vector falls into the \underline{\hspace{15mm}}. \item Often, the critical region is defined in terms of the value of a \underline{\hspace{15mm}} statistic. \item $H_0$ is rejected when the test statistic is beyond some particular number. That number is called a \underline{\hspace{15mm}}. \item Failure to reject the null hypothesis when the null hypothesis is false is called a \underline{\hspace{15mm}}. \item Rejection of the null hypothesis when the null hypothesis is true is called a \underline{\hspace{15mm}}. \item If the critical region of a test is denoted by $C$, then $\max_{\theta \in \Omega_0}P_\theta(X \in C)$ is called the \underline{\hspace{15mm}} of the test, and is usually denoted by the Greek letter \underline{\hspace{5mm}}. \item The maximum probability of rejecting $H_0$ when $H_0$ is true is called the \underline{\hspace{15mm}} of the test. \item The ``size" of a test is another term for the \underline{\hspace{15mm}}. \item The probability of correctly rejecting the null hypothesis is called the \underline{\hspace{15mm}} of the test. % \item \underline{\hspace{15mm}}. \end{enumerate} \pagebreak %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \item Do Exercise 6.3.1, except do it this way. \begin{enumerate} \item Write down a formula for the test statistic. \item What is the distribution of the test statistic? Is the distribution exact, or is it asymptotic? \item For $H_0: \mu=\mu_0$ versus $H_0: \mu \neq \mu_0$ with significance level $\alpha$ (which is what the authors intend in the question), \begin{enumerate} \item What is the set $\Omega_0$? \item What is the set $\Omega_1$? \item Give the critical value(s). \item Give the critical value(s) for $\alpha = 0.05$. The answer is numerical. \item Give the critical value(s) for $\alpha = 0.01$. The answer is numerical. \item What is the decision rule? That is, when will the null hypothesis be rejected? \item Calculate the test statistic. Show some work. The answer is a number. Circle your answer. \item Do you reject the null hypothesis at $\alpha = 0.05?$ Answer Yes or No. \item Calculate the $p$-value. The answer is a number. \item What do you conclude? Choose one of these answers. \begin{itemize} \item $\mu>5$ \item $\mu<5$ \item $\mu=5$ \end{itemize} \item The question asks for a 95\% confidence interval too, so you may as well do it. \end{enumerate} \item For $H_0: \mu \leq \mu_0$ versus $H_1: \mu > \mu_0$ with significance level $\alpha$, \begin{enumerate} \item What is the set $\Omega_0$? \item What is the set $\Omega_1$? \item Give the critical value(s). \item Give the critical value(s) for $\alpha = 0.05$. The answer is numerical. \item Give the critical value(s) for $\alpha = 0.01$. The answer is numerical. \item What is the decision rule? That is, when will the null hypothesis be rejected? \item You have already calculated the test statistic. Do you reject the null hypothesis at $\alpha = 0.05?$ Answer Yes or No. \item Calculate the $p$-value. The answer is a number. \item What do you conclude? Choose one of these answers. \begin{itemize} \item $\mu \leq 5$ \item $\mu>5$ \end{itemize} \item To show that the test really has significance level $\alpha$, you need to prove that $\max_{\mu \in \Omega_0} P_\mu(Z \geq z_{1-\alpha})$ occurs at $\mu=\mu_0$. Do it. \item Derive a general formula for the power of this test. Use $\Phi(\cdot)$ to denote the cumulative distribution function of a standard normal. (This is standard notation.) \end{enumerate} \item For $n=10$ and $\alpha=0.05$ as in the problem, find the power of the test when the true value of $\mu$ is 5.5. The answer is a number. Also find the power of the test when the true value of $\mu$ is 6. \item For $H_0: \mu \geq \mu_0$ versus $H_1: \mu < \mu_0$ with significance level $\alpha$, \begin{enumerate} \item What is the set $\Omega_0$? \item What is the set $\Omega_1$? \item Give the critical value(s). \item Give the critical value(s) for $\alpha = 0.05$. The answer is numerical. \item Give the critical value(s) for $\alpha = 0.01$. The answer is numerical. \item What is the decision rule? That is, when will the null hypothesis be rejected? \item Show that $\max_{\mu \in \Omega_0} P_\mu(Z \leq z_{1-\alpha})$ occurs at $\mu=\mu_0$. \item You have already calculated the test statistic. Do you reject the null hypothesis at $\alpha = 0.05?$ Answer Yes or No. \item Calculate the $p$-value. The answer is a number. \item What do you conclude? Choose one of these answers. \begin{itemize} \item $\mu \geq 5$ \item $\mu<5$ \end{itemize} \end{enumerate} % \end{enumerate} % End enhanced Exercise 6.3.1 \item Do Exercise 6.3.2 in a bit more detail, this way. \begin{enumerate} \item Write down a formula for the test statistic. \item What is the distribution of the test statistic under the null hypothesis -- that is, when $H_0$ is true? \item For $H_0: \mu=\mu_0$ versus $H_1: \mu \neq \mu_0$ with significance level $\alpha$ (which is what the authors intend in the question), \begin{enumerate} \item What is the set $\Omega_0$? \item What is the set $\Omega_1$? \item Give the critical value(s). \item Give the critical value(s) for $\alpha = 0.05$. The answer is numerical. \item Give the critical value(s) for $\alpha = 0.01$. The answer is numerical. \item What is the decision rule? That is, when will the null hypothesis be rejected? \item Calculate the test statistic. Show some work. The answer is a number. Circle your answer. \item Do you reject the null hypothesis at $\alpha = 0.05?$ Answer Yes or No. \pagebreak %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \item What do you conclude? Choose one of these answers. \begin{itemize} \item $\mu>5$ \item $\mu<5$ \item $\mu=5$ \end{itemize} \item The question asks for a 95\% confidence interval too, so you may as well do it. \end{enumerate} \end{enumerate} % End enhanced Exercise 6.3.2 \item Do Exercise 6.3.4 in a bit more detail, this way. Note that you can't calculate the $p$-value without using software, so the question as it is written is impossible for a test or exam. \begin{enumerate} \item Write down a formula for the test statistic. \item What is the distribution of the test statistic under the null hypothesis? \item For $H_0: \mu=\mu_0$ versus $H_0: \mu \neq \mu_0$ with significance level $\alpha$ (which is what the authors intend in the question), \begin{enumerate} \item What is the set $\Omega_0$? \item What is the set $\Omega_1$? \item Give the critical value(s). \item Give the critical value(s) for $\alpha = 0.05$. The answer is numerical. \item Give the critical value(s) for $\alpha = 0.01$. The answer is numerical. \item What is the decision rule? That is, when will the null hypothesis be rejected? \item Calculate the test statistic. Show some work. The answer is a number. Circle your answer. \item Do you reject the null hypothesis at $\alpha = 0.05?$ Answer Yes or No. \item What do you conclude? Choose one of these answers. \begin{itemize} \item $\mu>60$ \item $\mu<60$ \item $\mu=60$ \end{itemize} \item The question asks for a 95\% confidence interval too, so you may as well do it. \end{enumerate} \end{enumerate} % End enhanced Exercise 6.3.4 \item Do Exercise 6.3.5, as written. \item This is an adaptation of Question 3 on Assignment 3. The label on the peanut butter jar says peanuts, partially hydrogenated peanut oil, salt and sugar. But we all know there is other stuff in there too. There is very good reason to assume that the number of rat hairs in a jar of peanut butter has a Poisson distribution with mean $\lambda$, because it's easy to justify a Poisson process model for how the hairs get into the jars (technical details omitted). There is a government standard that says the expected number of rat hairs in a jar can be no more than 8. A sample of thirty 500g jars yields $\overline{X}_n=9.2$. \begin{enumerate} \item What null hypothesis should be tested to decide whether the company is in compliance with regulations? \item What is the alternative hypothesis? \item Suggest \emph{two} possible test statistics. Remember, all we know is the sample size and the sample mean. \item What is the distribution of the two test statistics under the null hypothesis? \item What is the set $\Omega_0$? \item What is the set $\Omega_1$? \item Give the critical value(s). \item Give the critical value(s) for $\alpha = 0.05$. The answer is numerical. \item Give the critical value(s) for $\alpha = 0.01$. The answer is numerical. \item What is the decision rule? That is, when will the null hypothesis be rejected? \item Calculate the values of \emph{both} test statistics. Show some work. The answers are numbers. \item Calculate both $p$-values. Show some work. The answers are numbers. \item With each test, do you reject the null hypothesis at $\alpha = 0.05?$ Answer Yes or No. \item What do you conclude? Choose one of these answers. \begin{itemize} \item $\lambda>8$ \item $\lambda \leq 8$ \end{itemize} \item Is there evidence that the company is in violation of the regulations? Answer Yes or No. \end{enumerate} % End of Poisson Rat hair question. % Direct p-value % > 1-ppois(x-1,240) % [1] 0.01226396 \item Do Exercise 6.3.11. In later classes (not this one), you might be expected to supply questions like the following on your own, and answer them. % This question is funky, and seems to endorse data snooping, or else to require a very hard theory involving the maximum frequency of a multinomial. There reason for choosing it is that the two natural Z statistics yield different conclusions. \begin{enumerate} \item Suggest a model for the sample data. \item What null hypothesis should be tested to decide whether the die is biased? I suggest a two-tailed test. \item What is the alternative hypothesis? \item Suggest \emph{two} possible test statistics. \item What is the distribution of the two test statistics under the null hypothesis? \item What is the set $\Omega_0$? \item What is the set $\Omega_1$? \item Give the critical value(s). \item Give the critical value(s) for $\alpha = 0.05$. The answer is numerical. \item Give the critical value(s) for $\alpha = 0.01$. The answer is numerical. \item What is the decision rule? That is, when will the null hypothesis be rejected? \item Calculate the values of \emph{both} test statistics. Show some work. The answers are numbers. \item Calculate both $p$-values. Show some work. The answers are numbers. \item With each test, do you reject the null hypothesis at $\alpha = 0.05?$ Answer Yes or No. \item What do you conclude for each test? Choose one of these answers. \begin{itemize} \item $\theta > \frac{1}{6}$. \item $\theta < \frac{1}{6}$. \item $\theta = \frac{1}{6}$. \end{itemize} \item Is there evidence that the die is biased? \end{enumerate} % End of biased die question. \item \label{twot} If the following example seems familiar, it's because it comes from Question~5 of Assignment~Four. Two surgeons in a cosmetic surgery practice decide to have a friendly competition. The wait list has 20 patients who want surgery to make their noses smaller. Ten patients are randomly assigned to Surgeon A, and the other ten are assigned to Surgeon B. A panel of medical students rate the facial appearance of the patients on a 100 point scale before surgery and again six weeks after. The number for each patient is improvement (according to the medical students): After minus before. Of course, the medical students are not told which doctor did the surgery. Because of scheduling problems and drop-out (people change their minds), Surgeon A only did nine surgeries, and Surgeon B did seven. So with $n_1=9$ and $n_2=7$, we have $\overline{x}=14.1$, $s^2_1=48.2$, $\overline{y}=13.3$, $s^2_1=32.7$. \begin{enumerate} \item State the model for this question. Given what we've done in this course so far, there is really only one choice. \item How could the Central Limit Theorem be used to justify a normal model for the attractiveness ratings? \item What is the parameter space for this model? \item What null hypothesis should be tested to decide which surgeon won the contest? \item What is the alternative hypothesis? \item In Question~5 of Assignment~Four, you derived the test statistic, which may also be found on the formula sheet. What is its distribution under the null hypothesis? \item What is the set $\Omega_0$? \item What is the set $\Omega_1$? \item Give the critical value(s) of the test statistic. \item Give the critical value(s) for $\alpha = 0.05$. The answer is numerical. \item Give the critical value(s) for $\alpha = 0.01$. The answer is numerical. \item What is the decision rule? That is, when will the null hypothesis be rejected? \item Calculate the numerical value of the test statistic. Show your work. The answer is a number. \item Do you reject the null hypothesis at $\alpha = 0.05?$ Answer Yes or No. \pagebreak %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \item What do you conclude? Choose one of these answers. \begin{itemize} \item $\mu_1 > \mu_2$. \item $\mu_1 < \mu_2$. \item $\mu_1 = \mu_2$. \end{itemize} \item Who won the contest? \end{enumerate} % End of two-sample t question. \item Suppose you want to test $H_0: \sigma^2_1 = \sigma^2_2$ versus $H_0: \sigma^2_1 \neq \sigma^2_2$. \begin{enumerate} \item Write down a formula for the test statistic. Look at your answer to Question 6 of Assignment 4 if you need to. \item What is the distribution of the test statistic under the null hypothesis? \item Prove your answer to the last part. Don't forget to say why numerator and denominator are independent. \item For the data of Question \ref{twot}, calculate the test statistic. Show a little work. The answer is a number. \item Find the critical values for $\alpha=0.05$ in the tables of the $F$ distribution in the back of the text. It's not part of the formula sheet. If I ask this on the test or final exam, I might have to give you just the correct page, and you find the critical value(s). \item What is the decision rule? \item Do you reject the null hypothesis? Answer Yes or No. \item What do you conclude? Pick one. \begin{itemize} \item $\sigma^2_1 > \sigma^2_2$. \item $\sigma^2_1 < \sigma^2_2$. \item $\sigma^2_1 = \sigma^2_2$. \end{itemize} \end{enumerate} \item You have done this problem quite a few times now. This is the last time you will have to do it for homework in this class. Let $X_1, \ldots, X_n$ be a random sample from a distribution with density $f(x)$ and cumulative distribution function $F(x)$. \begin{enumerate} \item Let $Y_1 = \max(X_i)$. \begin{enumerate} \item Derive the cumulative distribution function of $Y_1$. \item Derive the probability density function of $Y_1$. \end{enumerate} \item Let $Y_2 = \min(X_i)$. \begin{enumerate} \item Derive the cumulative distribution function of $Y_2$. \item Derive the probability density function of $Y_2$. \end{enumerate} \end{enumerate} Notice that since $f(x)$ includes an indictor for the support, the minimum and maximum both have the same support as the original distribution. This makes sense. \pagebreak %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \item Let $X_1, \ldots, X_n$ be a random sample from an Exponential$(\lambda)$ distribution, and we seek to test hypotheses about $\lambda$. In lecture, you saw a couple of test statistics based on $\overline{X}_n$. In this question, the test statistic will be $Y = \max(X_i)$. As in lecture, the focus will be on $H_0: \lambda \geq \lambda_0$ versus $H_1: \lambda < \lambda_0$. Again, since $E(X_i) = \frac{1}{\lambda}$, long average wait times correspond to small values of $\lambda$, and if the average wait time were under two months, then it would be surprising to get a maximum wait time that was very large, like six years. Thus, $H_0$ will be rejected if $Y \geq k$, for some well-chosen $k$. \begin{enumerate} \item Write a formula for the cumulative distribution function of the test statistic $Y$. Use indicator functions. \item Give a formula for $P_\lambda(Y \geq k)$, where $k>0$. \item Show that the maximum probability of rejecting $H_0$ when $H_0$ is true is attained when $\lambda=\lambda_0$. \item Determine the critical value $k$ so that the test will have significance level $\alpha$. Derive an explicit formula. Show your work. \item Give the critical value for testing $H_0:\lambda \geq \frac{1}{2}$ versus $H_1:\lambda<\frac{1}{2}$ with $\alpha=0.05$ and $n=29$. The answer is a number. \item A random sample of size $n=29$ yields a maximum value of $y=10.25$. \begin{comment} > -2*log(1-0.95^(1/n)) [1] 12.67675 \end{comment} \begin{enumerate} \item What is the $p$-value? The answer is a number. Show your work. \item There are two ways to decide whether to reject the null hypothesis? What are they? \item Do you reject the null hypothesis? Answer Yes or No. \item What do you conclude? Pick one. \begin{itemize} \item $E(X_i) \leq 2$. \item $E(X_i) > 2$. \end{itemize} \end{enumerate} \item Suppose that the true value of $\lambda$ is $0.4$, so that the null hypothesis is false in this particular way. We wonder about the probability of correctly rejecting the null hypothesis. Still with $\alpha = 0.05$, \begin{enumerate} \item What is the power of the test with $n=29$ (the sample size we actually had)? The answer is a number between zero and one. \item What is the power of the test with $n=290$? The answer is a number between zero and one. \end{enumerate} \end{enumerate} % End of the maximum exponential question \item Suppose we have two independent random samples from exponential distributions. Suggest an exact $F$-test of $H_0: \lambda_1 = \lambda_2$ based on the sample means. Use page~3 of the new formula sheet. % Some ideas % CI <=> test % p ~ U(0,1) % Meta-analysis of p-values. % Independent exponentials, exact F test for H0: lambda1 = lambda2 % \end{enumerate} % End of all the questions % \vspace{90mm} \vspace{3mm} \hrule %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \vspace{3mm} \noindent This assignment was prepared by \href{http://www.utstat.toronto.edu/~brunner}{Jerry Brunner}, Department of Mathematical and Computational Sciences, University of Toronto. It is licensed under a \href{http://creativecommons.org/licenses/by-sa/3.0/deed.en_US} {Creative Commons Attribution - ShareAlike 3.0 Unported License}. Use any part of it as you like and share the result freely. The \LaTeX~source code is available from the course website: \begin{center} \href{http://www.utstat.toronto.edu/~brunner/oldclass/260s20} {\small\texttt{http://www.utstat.toronto.edu/$^\sim$brunner/oldclass/260s20}} \end{center} \end{document} \item Bring back the beta? \begin{enumerate} \item \item \end{enumerate} % 6.3.9 is ns, 6.3.11 Say use alpha = 0.05. \vspace{3mm} \hrule %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \vspace{3mm} # Maximum exponential question set.seed(9999) n = 29; trueL = .4 x = rexp(n,rate=trueL) summary(x) c(mean(x), var(x)) > summary(x) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.3102 1.1932 2.3283 2.9377 4.3208 10.2475 > c(mean(x), var(x)) [1] 2.937707 5.898982 # Analysis lambda0 = 1/2; alpha = 0.05; n = 29; lambda = 0.4 k = -1/lambda0 * log(1-(1-alpha)^(1/n)) ; k pow = 1-(1-exp(-lambda*k))^n ; pow