\documentclass[30pt,landscape]{foils}

\usepackage{amsmath}

\usepackage{pause}               \usepackage{background}
\usepackage{graphicx}           \usepackage{geometry}
\usepackage{hyperref}

\usepackage{pp4slide}
\geometry{headsep=3ex,hscale=0.9}

\newtheorem{example}{Example} 
\newtheorem{question}[example]{Question}
\newtheorem{definition}[example]{Definition}
\newtheorem{theorem}[example]{Theorem}
\newtheorem{fact}[example]{Fact}
\newtheorem{notation}[example]{Notation}

\newcommand{\pz}{\pause}
\newcommand{\pb}{\pagebreak}

\definecolor{bgblue}{rgb}{0.03,0.39,0.23}
\vpagecolor{bgblue}

\hypersetup{pdftitle={lecture},
  pdfsubject={A mathematics lecture},
  pdfauthor={Dev Sinha, University of Oregon},
  pdfkeywords={pdftex, acrobat},
  pdfpagemode={FullScreen},
  linkcolor={red}
}

\begin{document}


{\Large Testing hypotheses} \pz

Our focus in these last weeks of class will be almost exclusively on 
confidence intervals and hypothesis testing.  \pz  Last time we
slowly developed the language and methods of basic hypothesis testing. \pz
We will review these now but be more direct. \pb

\noindent{\bf General setup}: Suppose you are studying some random
variable of some population.  
Suppose someone else makes a guess that the mean
\[
\mu =\mu_{0}
\]
for some number $\mu_{0}$.   (And suppose that you \emph{know} the standard
deviation, $\sigma$ for the population.  We'll remove this assumption
when we study  \S  16).\pause 

You suspect that $\mu_{0}$ is incorrect;  that is that 
\[
\mu \ne \mu_{0}.
\]\pause 
Your audience will be convinced, if you can show that 
\[
P (\mu = \mu_{0}) < \alpha. \pz
\]
($\alpha$ is typically .05 or .1 or .01).  \pz  Our setup is now:\begin{itemize}
\item  {$H_{0}: \mu =\mu_{0}$}.   {Null hypothesis.}
\item  {$H_{a}: \mu \ne \mu_{0}$}.  {Alternative hypothesis.}
\item  {Significance level $\alpha$.}
\end{itemize}\pause 

To try to convince an audience that $H_{0}$ is wrong (to
{\em reject the null hypothesis}) we do the following:
\begin{enumerate}
\item [a.] Take a SRS from population of size $n$.\pause 
\item [b.] Calculate $\overline{x}$ (our sample mean) and the
$z$-statistic 
\[
z = \frac{\overline{x}-\mu_{0}}{\sigma /\sqrt{n}}
\]\pb
\item [c.] Calculate the ``P-value:'' = the probability (assuming
$H_{0}$ is true) that $\overline{x}$ is at least this far from
$\mu_{0}$ \pause  
\begin{multline*}
= P (\mbox{sample mean} \geq \mu_{0} +|\overline{x}-\mu_{0}|) +\\
   P (\mbox{sample mean} \leq \mu_{0} -|\overline{x}-\mu_{0}|) \pz \\ 
= P (Z \geq |z|) + P (Z \leq -|z|).
\end{multline*}
\pb
\item [d.]  If $P \leq \alpha$ this is \emph{statistically significant
at level $\alpha$} and leads you to reject the null hypothesis.  If
$P > \alpha$ this is not statistically significant at that
significance level, which means that you can neither reject or accept the 
null hypothesis.\pb
\end{enumerate}

\noindent NOTE:  We are concentrating on the situation where $H_{0}$
is of form $\mu =\mu_{0}$.  $H_{a}$ can be serveral things.  Either
\begin{itemize}
\item $H_{a}: \mu \ne \mu_{0}$ (if we don't know which way $\mu$ might
be off from $\mu_{0}$).  This is called the \em{two-sided alternative}.\pause 
\item $H_{a}: \mu >\mu_{0}$ (if we suspect $\mu$ might really be
larger than $\mu_{0}$).  This is called a \em{one-sided alternative}.\pause 
\item $H_{a}:\mu <\mu_{0}$ (if we suspect $\mu$ might really be
smaller than $\mu_{0}$).  This is another one-sided alternative.
\end{itemize}

\pb 
\begin{example}
 Height of men in their 20s in the US is
$N (69.3, 2.8)$.  \pz 
We suspect that the mean height of UO undergrad men
is larger than this. \pz
\begin{itemize}
\item Hypotheses: $H_{0}:\mu =69.3$.  $H_{a}: \mu >69.3$. \pz
\item Calculate $z$-statistic:  We take a SRS of 32 undergrad men from the UO.  
We discover that $\overline{x} = 70.4$ and then that 
\[
z = \frac{70.4-69.3}{2.8/\sqrt{32}}  = 2.22. \pz
\]
\item Calculate $P$-value: $P (Z \geq 2.22) = .0132$ from table A.  \pz
\item Conclusion: If $H_{0}$ is \emph{true}, the probability that
$\overline{x} \geq 70.4$ is only .0132.  This is evidence against
$H_{0}$ \pz  This $P$-value gets smaller if
we assume that $\mu$ is even smaller than $69.3$, so in fact it
gives evidence for $H_a$. \pz


At significance level $\alpha =.05$ this is statistically significant
so we reject the null hypotheses and believe $H_{a}$ is probably true. \pz

At significance level $\alpha =.01$ this is not statistically significant
so we don't reject the null hypotheses.  (Although it may still be false.) \pb
\end{itemize}
\end{example}

\begin{example}
SAT scores are roughly normally distributed with a mean of 1682
and a deviation of 220.  \pz  You want to know if TestQuick test preparation
helps improve scores.  A random sample of 625 students who have used
TestQuick are chosen, and they score an average of 1695. \pz  Is this
convincing evidence that TestQuick improves scores?  If so, at 
what level is it convincing? \pb
\end{example}

\begin{example}
Yearly household incomes in the U.S have a mean of 
38 thousand and a standard deviation which is less than 
forty thousand dollars.  \pz  You do a random survey of 1600 housholds
in Oregon and you find an average income of 35 thousand.  Is
this convincing evidence that household incomes in Oregon
are on average less than the national average? \pz
\end{example}

\pb

{\large Relating hypothesis testing to confidence intervals} \pz

The basic calculations for hypothesis testing and confidence intervals
are the same: \pz take a simple random sample, compute its mean,
and then calculate its $z$-statistics using the Central Limit Theorem.  \pz

In fact, these two procedures are logically related \pz (seeing
how helps us better understand both concepts). \pb

\begin{fact}
If some guess for a mean $\mu_0$ is not within a $1-\alpha$
confidence interval about an observed mean $\bar{x}$ then we
may reject the null hypothesis $\mu = \mu_0$ at significance
level $\alpha$. \pz
\end{fact}

It helps to sketch a picture of what this is saying and to choose some 
concrete numbers. \pz

\begin{example}
Suppose a variable has a standard deviation of $5$ and a measured mean
of  $172.1$ from a sample size of $80$.  \pz \\
\begin{itemize}
\item Find a confidence interval with $C = 95\%$ for this variable. \pz
\item Show that the null-hypothesis of a mean equal to  $175$ can 
be rejected at level $5\%$. \pb
\end{itemize}
\end{example}


{\Large Caution: garbage in, garbage out} \pz

The most common mistakes one sees in applications of
statistics are not in the mathematics of means and deviations \pz  --
with practice one can master these methods, and there
are sophisticated computer packages to help out \pz --
but in starting with biased data, whose error is comparable to
the confidence intervals in question. \pz

\begin{example}
What if in our UO height example, two of the sample taken were
members of the basketball team over 80 inches tall? \pz 
If these outliers are thrown out, what is our new confidence level
for the hypothesis that UO men are above average height? \pz
\end{example}

One of the topics of Chapter 15 is to elaborate on problems which
can plague samples and surveys, in light of their effects on 
confidence intervals and hypothesis tests.  \pz  This material 
mostly applies common sense, not mathematics, as we did
when we looked at designing surveys and experiemens.   \pz  

We will not at all cover the material from Chapter 15 on type I and II errors
and power of tests.  \pz  This development of language is straightforward enough
so that you could learn it on your own if you encountered these terms outside
of class.  \pb


\end{document}


{\Large Summary of confidence intervals} \pz

Informally, a confidence interval gives a likely range for some value. \pz
More formally, it is a statement of the form ``with a $C\%$ probability, 
the value of interest is between some number 
$A$ and some other number $B$.'' \pz

There are two basic mathematical ideas behind confidence intervals. \pz

The first is that when a distribution is normal, 
an observation is often within a few standard deviations of the mean. \pz

The second idea, culminating in the Central Limit Theorem, says that 
large samples have a standard deviation which goes down by the square
root of the sample size. \pb

\noindent {\bf Computing confidence intervals} \pz
\begin{enumerate}
\item Identify the desired confidence level $C\%$. \pz
\item Let $O$ be observed value (of the sample).  \pz
\item Identify the standard deviation of the relevant (sampling) distribution, 
call it $S$. \pz
\item Identify the kind of distribution which is relevant for 
the problem, $z$ if the standard deviation of the entire
population is known or $t$ if you only know the deviation of your sample. \pz
\item Look up the critical value associated to the confidence level $C\%$.
Call this critical value $v^*$. \pz
\item The margin of error for the observation is $v^* \times S$. \pz  In each
setting one can work backwards from this equation to determine how
large a sample is needed or what level of confidence is needed
to result in a desired margin of error. \pz
\item The confidence interval says that with $C\%$ probability the 
value of interest is between $O - (v^* \times S)$ and $O +( v^* \times S)$. \pb
\end{enumerate}

\noindent {\bf Instances of confidence intervals} \pz
\begin{itemize}

\item Sampling for a mean when the deviation over the entire
population, $\sigma$,  is known: \pz
\begin{itemize}
\item The observed value, the mean of the sample, is denoted $\bar{x}$. \pz
\item The deviation for the a sample of size $n$ is $\frac{\sigma}{\sqrt{n}}$. \pz
\item The relevant distribution is a $z$-distribution. \pz
\item Look up the critical value $z^*$ in the last row of Table C. \pb
\end{itemize}

\item Sampling for a mean when only the deviation of the 
sample is known. \pz
\begin{itemize}
\item The observed value, the mean of the sample, is denoted $\bar{x}$. \pz
\item The deviation for the a sample of size $n$ is $\frac{s}{\sqrt{n}}$,
where $s$ is the deviation of the sample (a.k.a. the standard error). \pz
\item The relevant distribution is a $t({n-1})$-distribution. \pz  (One must be
careful that the sample data is either large or close to normal). \pz 
\item Look up the critical value $t^*$ in the appropriate row of Table C. \pb
\end{itemize}

\item Sampling for a difference of means between two distributions
(when only the deviations of the samples are known). \pz
\begin{itemize}
\item The observed value is the difference of the observed means $\bar{x}_1 - \bar{x}_2$. \pz
\item The deviation is $\sqrt{\frac{{s_1}^2}{n_1} + \frac{{s_2}^2}{n_2}}$, where
the first sample has size $n_1$ and deviation $s_1$ and the second sample has
size $n_2$ and deviation $s_2$. \pz
\item The relevant distribution is a $t(N)$ distribution, where $N$ is the smaller of
$n_1-1 $ and $n_2  - 1$.  (One must be
careful that the sample data is either large or close to normal). \pz 
\item Look up the critical value $t^*$ in the appropriate row of Table C. \pb
\end{itemize}

\item Sampling for a proportion. \pz
\begin{itemize}
\item The observed value is the proportion of positive (Yes) responses
in the survey, $\hat{p}$. \pz
\item The deviation for a sample of size $n$ is $\sqrt{\frac{\bar{p}(1 - \bar{p})}{n}}$,
where $\bar{p}$ is the proportion assuming four more responses, two of which
are positive.  (This is ``plus four'' method, needed almost always). \pz
\item The relevant distribution is the standard, normal $z$ distribution. \pz
\item Look up the critical $z^*$ value in the last row of Table C. \pb
\end{itemize} 

\item Sampling for a difference of proportions. \pz (NEW!) \pz  Only in use
with large samples. \pz
\begin{itemize}
\item The observed value is the difference of proportions of positive responses
between two populations being surveyed, $\hat{p_1} - \hat{p_2}$. \pz
\item The deviation is 
$$\sqrt{ \frac{\hat{p_1}(1-\hat{p_1})}{n_1} +  \frac{\hat{p_2}(1-\hat{p_2})}{n_2} }. $$\pz
\item The relevant distribution is the standard, normal $z$ distribution. \pz
\item Look up the critical $z^*$ value in the last row of Table C. \pb
\end{itemize}
\end{itemize}

\begin{example}
Give statements of problems where each kind of sampling is relevant. \pz
\end{example}

\begin{example}
500 men and 500 women who regularly vote in Oregon were asked whether
they approved of Gov. Kulongoski's handling of his job.  \pz 172 of the men said they did,
and 191 of the women said they did. \pz Give a 95\% confidence interval
for the difference of approval ratings which men and women give the Governor. \pb
\end{example}

{\Large Summary of hypothesis testing} \pz

The logic of hypothesis tests is trickier. \pz A good example to keep in mind is ``what 
would you think if you flipped a coin twenty times and it came up heads each time?'' \pz
You would think that the coin is not a standard (50-50 chance of Heads-Tails) coin! \pz
Here a null-hypothesis, \pz that the coin is fair, \pz and an observation, \pz
of twenty heads, \pz are at odds.  \pz  The probability of getting twenty heads in a 
row assuming a fair coin is less than one in a million! \pz  The fact that we saw twenty
heads in a row thus gives evidence against the hypothesis that the coin is fair, \pz
and thus for the alternative hypothesis that the coin is biased (to give more heads). \pz

In abstract language, one has a null hypothesis A and an observation B.  \pz
If the probability of B assuming A (the P-value) is very small, this gives evidence
against A and thus for alternatives.  \pz If this P-value is not small, the test is inconclusive
\pz - you can neither refute A nor can you accept A. \pz  The computation of a P-value
is ultimately very similar to the kinds of probabilities on normal distributions we did
in the first half of the class. \pb

\noindent {\bf Computing hypothesis tests}

\begin{enumerate}
\item Identify the null and alternative hypotheses. \pz
\item Let $O$ be observed value (of the sample).  \pz
\item Identify the standard deviation of the relevant (sampling) distribution, 
call it $S$. \pz
\item Identify the kind of distribution which is relevant for 
the problem, $z$ if the standard deviation of the entire
population is known or $t$ if you only know the deviation of your sample. \pz
\item Compute the standardized variable $t \;\; {\rm or} \;\; z  = \frac{O - H}{S}$, which
measures how many deviations away $O$ is from the value $H$ predicted
by the null hypothesis. \pz
\item If the distribution is normal, use Table A to calculate the probability
of observing a value less than a negative $z$ or bigger than a positive $z$. \pz
\item If a $t$-statistic is needed, work ``backwards'' from Table C to find the
probability of observing a value less than a negative $t$ (by first converting
a negative to a positive) or greater than a positive $t$. \pz
\item This probability is equal to the probability of observing something less than/ bigger
than $O$ assuming the null hypothesis. \pz It is called the $P$-value. \pz
\item If the $P$-value is less than 
$\alpha$, we say the null-hypothesis has
been rejected (and thus the alternative hypothesis accepted) at level $\alpha$.  \pz   
If the $P$-value is not less than our desired $\alpha$ we say the test is
inconclusive. \pb
\end{enumerate}

\noindent {\bf Instances of hypothesis testing} \pz
\begin{itemize}

\item Hypothesis testing of a mean when the deviation over the entire
population, $\sigma$,  is known: \pz 
\begin{itemize}
\item The observed value, the mean of the sample, is denoted $\bar{x}$. \pz
The hypothesized value is often denoted $\mu_0$. \pz
\item The deviation for the a sample of size $n$ is $\frac{\sigma}{\sqrt{n}}$. \pz
\item The relevant distribution is a $z$-distribution. \pb
\end{itemize}

\item Hypothesis testing of a mean when only the deviation of the 
sample is known. \pz
\begin{itemize}
\item The observed value, the mean of the sample, is denoted $\bar{x}$,
and the hypothesized value is often denoted $\mu_0$. \pz
\item The deviation for the a sample of size $n$ is $\frac{s}{\sqrt{n}}$,
where $s$ is the deviation of the sample (a.k.a. the standard error). \pz
\item The relevant distribution is a $t({n-1})$-distribution. \pz  (One must be
careful that the sample data is either large or close to normal). \pb
\end{itemize}

\item Hypothesis testing of  a difference of means between two distributions
(when only the deviations of the samples are known). \pz
\begin{itemize}
\item The observed value is the difference of the observed means $\bar{x}_1 - \bar{x}_2$. \pz
The hypothesized value is usually denoted $\mu_1 - \mu_2$, and is
frequently zero. \pz
\item The deviation is $\sqrt{\frac{{s_1}^2}{n_1} + \frac{{s_2}^2}{n_2}}$, where
the first sample has size $n_1$ and deviation $s_1$ and the second sample has
size $n_2$ and deviation $s_2$. \pz
\item The relevant distribution is a $t(N)$ distribution, where $N$ is the smaller of
$n_1-1 $ and $n_2  - 1$.  (One must be
careful that the sample data is either large or close to normal). \pb
\end{itemize}

\item Hypothesis testing of  a proportion. \pz
\begin{itemize}
\item The observed value is the proportion of positive (Yes) responses
in the survey, $\hat{p}$. \pz
\item The deviation for a sample of size $n$ is $\sqrt{\frac{\bar{p}(1 - \bar{p})}{n}}$,
where $\bar{p}$ is the proportion assuming four more responses, two of which
are positive.  (This is ``plus four'' method, needed almost always). \pz
\item The relevant distribution is the standard, normal $z$ distribution. \pb
\end{itemize} 

\item Hypothesis testing of a difference of proportions. \pz 
\begin{itemize}
\item The observed value is the difference of proportions of positive responses
between two populations being surveyed, $\hat{p_1} - \hat{p_2}$. \pz
\item The deviation is 
$$\sqrt{ \hat{p}(1-\hat{p})\left( \frac{1}{n_1} +  \frac{1}{n_2} \right) },$$
where $\hat{p}$ is the total proportion is positive responses over both samples. \pz
\item The relevant distribution is the  normal distribution. \pb
\end{itemize}
\end{itemize}

\begin{example}
Give examples in which each of these hypothesis testing techniques would be 
relevant.  \pz Discuss in particular the difference between matched-pair
and two-population experimental design. \pz
\end{example}

\begin{example}
With numbers as in Example~2, does this survey give good evidence that 
women are more likely to approve of Gov. Kulongowski?
\end{example}



\end{document}
 