\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  The Big Picture: Statistical Estimation} \pz

With our understanding of probability \pz - plus one huge
fact we will soon cover - \pz we can now go back to the important
central question of with what certainty we may draw conclusions
from random surveys and samples of data. \pz

We use the term  {\em population} refers to the total population we wish to
study and the  {\em sample} refers to a particular (usually much
smaller) group of the population we have information on. \pz

Suppose we wish to measure the mean
amount people spend purchasing a car in the U.S.  We call this a
 \emph{parameter}.  It is almost impossible to calculate this
number, as will be the case with most parameters we study. \pz
Instead we may interview 1000 people, and get a  \emph{statistic} based
on that 1000 people.  Eventually, we would like some idea how well our
statistic approximates our parameter. \pz

One of the most common parameters we want to measure is the mean
of an entire population,
which we now denote by $\mu$.  \pz  The associated statistic, 
which is the mean of some sample, will be denoted our
usual $\overline{x}$. \pz

\begin{definition}
\begin{itemize}
\item A  {parameter} is  some feature of your  {population} that
you are interested in. \pz
\item A  {statistic} is some feature of your  {sample} with
which you would like to approximate the parameter. \pz
\end{itemize}  
\end{definition}

One of the basic facts of probability and statistics
is that if one takes larger and larger samples
from a population, a statistic will approach its
corresponding parameter (so for example $\overline{x}$
will approach $\mu$).  \pz
When formalized, this  is called the ``Law of Large Numbers.''  \pz
But this does not help us in our ultimate goal of extrapolating
data \pz  It says for example that we approach the
right answer if we can survey larger and larger random
samples of car buyers. \pz   But if we can only sample 1000
people, then what we really want to know is how
close we are to the actual parameter ``in all likelihood.'' \pb


{\Large Sampling distributions} \pz

A basic practice in statistics is to take a distribution and 
{\em sample} from it. \pz

\begin{definition}
Given a population,  the  {sampling
distribution} for samples of size $n$ is the probability distribution
of some parameter 
as we take values $n$ times. \pz
\end{definition} 

We go thoroughly through an example looking
at sampling distributions and comment
thoroughly as we go along. \pb

Consider the collection of numbers 
\[
\mathbf{S} = \{2,2,5,6,7 \}.
\]
 What is the mean? \pz  Ans: 4.4.  \pause 
 
 We can consider all samples from our collection of size $1$.  There
are 5 of them and again, the mean of the samples is again $4.4$.  The
standard deviation is 2.302.\pb


We can now consider all samples from $\mathbf{S}$ of size $2,$
and take the mean of each sample.  \pz Our samples are
\begin{multline*} 
\{\{2,2 \},\{2,5 \},\{2,6 \},\{2,7 \},\{2,5 \},\{2,6 \}, \\
 \{2,7 \},\{5,6 \},\{5,7 \},\{6,7 \} \}.
\end{multline*} \pause 
Our means are 
\[
\{2,3.5, 4, 4.5, 3.5, 4, 4.5, 5.5, 6, 6.5 \}
\] \pz
Notice that the spread is smaller, even though there are more numbers. 
The mean is still 4.4, and the standard deviation is now 1.329.\pause 

The probability distribution of these numbers is an example of
 {\em sampling distribution}.   \pz In this case 
it is for the mean of a sample of 2 from the set $\mathbf{S}$.  \pz
 There are 7 possible outcomes which \emph{don't} have equal probabilities. \pz

\noindent \begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
$X$ &  2 & 3.5 & 4 & 4.5 & 5.5 & 6 & 6.5   \\ \hline
Probability & .1  & .2 &  .2 & .2 & .1 & .1 & .1\\ \hline \pz
\end{tabular}
\pb

Now consider all samples of size 3, and their means.  \pz There are
again 10 such samples (you might recall this from our digression 
on binomial coefficients), which we won't list.  \pz  The means for these 10
samples are 
\[
\{3, 3.333, 3.667, 4.333, 4.667, 4.333, 4.667, 5, 5, 6 \}
\] \pz
The standard deviation is now only .886. \pz

Our  {sampling distribution} for samples of $3$ out of our original
group $S$ is 

\noindent \begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
$X$ &  3 & 3.333 & 3.667 & 4.333 & 4.667 & 5 & 6   \\ \hline
Probability & .1  & .1 &  .1 & .2 & .2 & .2 & .1\\ \hline
\end{tabular}

\pz

\begin{example}
Calculate the sampling distribution for the mean of samples of two 
out of the data set $\{-1, 0, 0, 2, 3, 6\}$. Graph both the original distribution
and the sampling distribution. \pz  
\end{example}

\pb

The process of taking a sampling distribution is not an easy one to understand the
first time you see it; go through this example and the book carefully.  \pz

There are two important cases of sampling distributions.   The first is one we
have seen in a different language. \pz

\begin{theorem}
The sampling distribution measuring number of heads in $n$ coin flips is called
the {\em binomial distribution}, with values giving by Pascal's triangle. \pz
As $n$ gets large, the sampling distribution for the number of heads
approaches a normal distribution, $N(\frac{n}{2}, \frac{\sqrt{n}}{2})$. \pz
\end{theorem}

\begin{example}
What is the probability, approximately, of getting more than $550$ heads
when flipping a coin $1000$ times?\pz
\end{example}

 The next theorem brings us closer to the techniques we will ultimately
 use to do statistics.\pz

\begin{theorem}
The sampling distribution for the mean of $n$ measurements of some data which
is known to be following a distribution of $N( \mu, \sigma)$ is itself normal, given
by $N(\mu, \sigma / \sqrt{n})$. \pz
\end{theorem}

\begin{example}
For men's heights, distributed according to $N (70,4)$, what is the probability that 
nine men chosen at random have an average height between $70$ and $73$? \pz
\end{example}

Compare this with our previous answer as to the probability of finding a single
man with such height.


\pb

{\large Facts about  {sampling distributions}}


We see in these examples that the sampling distribution of size $n$ 
always has the same mean as the original list \pz 
and has a standard deviation which is decreasing as the size gets larger. \pz

\begin{theorem}
Let $X$ be a population with mean $\mu $  and standard deviation
$\sigma $.  \pz

Consider the  {sampling distribution} of means of samples of size
$n$ from our population. \pz
\begin{itemize}
\item The mean of the sampling distribution is again $\mu$. \pz
\item The standard distribution of the sampling distribution is $\sigma /\sqrt{n}$. \pz
\item If our population is $N (\mu ,\sigma)$ then our sampling
distribution is $N (\mu ,\sigma /\sqrt{n})$. \pz
\end{itemize}
\end{theorem}

These features of sampling distributions, which are true in general, 
will be critical in making statistical inferences. \pz


\newpage

{\Large The Central Limit Theorem} \pz

\begin{theorem}
 The sampling distribution of means of random samples of size $n$ from a
population with mean $\mu$ and standard deviation $\sigma$ is
approximately 
\[
N (\mu ,\sigma /\sqrt{n})
\]
when $n$ is large.  \pz
\end{theorem}

This theorem is true no matter what the original distribution of
our population is!  \pz (unlike the previous theorem) \pb

This theorem is key to the kingdom of statistics. \pz
Think of what is happening to the standard deviation \pz - getting smaller. \pz
What does that tell us? \pz  Knowing the deviation of the sampling
distribution and the fact that it is approximately normal, 
we know how likely it is that a sample 
is within that deviation (or some multiple) from the mean. \pz
So we can understand our basic question: how far our
sample mean probably is from the real mean. \pz

Before we do precisely these kinds of computations, let's
see the Central Limit Theorem in action. \pb

\begin{example}
We look at the grade distribution for an exam. \pz

\includegraphics[width=15cm]{Figures/exam1-hist.pdf}\pb

Now we take means of all samples of size 2, and look at the histogram
of those numbers.  (There are 7875 such samples.) \pz

\includegraphics[width=15cm]{Figures/exam1-hist2.pdf}\pb

Now samples of size 3. (325500)

\includegraphics[width=15cm]{Figures/exam1-hist3.pdf}
\end{example}

\newpage

\begin{example}
Suppose that the average price of a new car purchase is \$24145
with a standard deviation of \$3615. \pz  Suppose you take a 
survey of 1000 car purchases.  What is the probability that the average
over your survey is over \$25000?
\end{example}\pb

\end{document}

{\large Example: Process Control} \pz

The Central Limit Theorem has many applications, since sampling
can be useful well beyond the realms of surveys and opinion polls. \pz

\begin{itemize}
\item 
Imagine a manufacturing process for, say, ball bearings.  The bearings
are supposed to be 10 mm in diameter.  In fact, when the manufacturing
process is working correctly, they are distributed normally $N
(10,.7)$. \pb

\item 
We can't check every bearing as it is too time consuming.  Every hour
we take a sample of 10 bearings, and take the mean diameter.  The
sample distribution of the means,  $\overline{x}$ should be $N
(10,.7/\sqrt{10})  = N (10,.221)$.  \pz

\item 
This means (by the 68-95-99.7 rule) 99.7\% of the means will occur
\[
10-3 (.221) < \overline{x} < 10+3 (.221) 
\]
\[
9.337 <
\overline{x} < 10.663 \pz
\]

We are alarmed if we see any $\overline{x}$ outside of these limits,
and suspect that our manufacturing process has been disturbed. \pz

\item 
We keep track with a  {$\overline{x}$ control chart}.  This is a
graph, with a mark each hour for the value of $\overline{x}$ for that
hour.   \pz

The graph includes an  {upper control line} 3 standard deviations
above the mean, and a  {lower control lines}, 3 standard deviations
below the mean. \pz

\includegraphics[width=15cm]{Figures/control-plot.pdf} \pz

Notice the entry above the upper control line.  Since 99.7\% of the
entries should be between the control lines,  we should only get
entries outside of that range about 3/1000 times. \pz

So an entry above the upper control line should be a rare event and
should mean that we check our production line to see if problems have
developed. \pz


\end{itemize}




\end{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.  \pz
Suppose someone else makes a guess that the mean
\[
\mu =\mu_{0}
\]
for some number $\mu_{0}$. \pause   (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.) \pz
\end{itemize}
\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


{\Large \S  16: Chapters 13 and 14 \emph{without} knowing $\sigma$} \pz

In \S 13 the method we learned for estimating our population mean $\mu$ 
had the serious drawback that we had to know the standard deviation
for our population.    We now wish to approximate $\mu$ \emph{without}
knowing the standard deviation.\pb

\noindent {\bf{Basic Idea:}} Take SRS.  Calculate the standard
deviation of our sample, $s$.  This is called the \emph{standard error}
to distinguish it from the unknown standard deviation of our
population.  \pz

Calculate the mean of our sample $\overline{x}$.  Use $s$ to estimate
$\sigma$ and then techniques we've already learned to estimate $\mu$
from $\overline{x}$.\pb

TERMINOLOGY:  We use 
\[
{\mu} = \mbox{for our (unknown) \pause  {population mean},}\pause \]
 and 
\[
{\overline{x}} = \mbox{for our \pause {sample
mean}.} \pause 
\]
We now also need to distinguish between two standard deviations.
\[
{\sigma} = \mbox{for our (unknown) \pause  {populations standard
deviation}} \pause 
\]
and
\[
{s} = \mbox{for our \pause  {sample standard deviation}.}
\] \pz

Recall that if our population has distribution $N (\mu ,\sigma)$ and we
look at samples of size $n$,  our standardized sample mean
\[
z = \frac{\overline{x}-\mu}{\sigma /\sqrt{n}}
\]
has distribution $N (0,1)$.\pause 

If we look instead at the random variable 
\[
t = \frac{\overline{x}-\mu}{ {s}/\sqrt{n}}
\]
this is called the  \emph{t-statistic}. \pz

The t-statistic looks much like the z-statistic we used when 
we assumed knowledge of the true deviation.  \pz
We give the t-statistic a distinct name because unlike
the z-statistic it is {\em not} normally distributed.  \pz
If we applied the 68-95-99.7 rule, we would get incorrect 
answers! \pz

Instead, we must understand where the t-statistic
fits on what is called
the  {\em t-distribution with $n-1$ degrees of freedom}.  This
distribution is abbreviated $t(n-1)$, \pz and looks like a
normal distribution with ``fat tails'', which arise because of the
uncertainty of not knowing the true standard deviation. \pause 
If $k$ is large, $t (k) \sim  N (0,1)$. \pause 

The critical values for t-distributions are in Table C. \pz
We can check by comparing with the last row  
that with a t-statistic you need to be more deviations
away from the mean to have the same level of confidence
as a z-statistic. \pz

\begin{example}
Use $t$-statistics to estimate population mean with confidence 95\% if we
have an SRS of size $n=11$ with $\overline{x}=27$ and $s=2$.\pause 
\end{example}

\begin{example}
With data as above, say whether or not the null-hypothesis of $\mu = 30$
can be rejected. \pz
\end{example}

%\begin{itemize}
%\item Look for $t^{*}$ with 95\% of $t (10)$ between $t^{*}$ and
%$-t^{*}$.  \pause 
%\item From table C, $t^{*}=2.359$.\pause
%\item So 
%\[
%-t^{*} = -2.359 \leq \frac{\overline{x}-\mu}{ {s}/\sqrt{11}} \leq 2.359 =
%t^{*}.
%\]\pause 
%Using our numbers,  $\mu$ is $\overline{x} \pm
%2.359\frac{2}{\sqrt{11}} = 27 \pm 1.4225.$
%\end{itemize}

\newpage



\end{document}

Matched pairs $t$-procedures (14.3).\pause 

Look for significance level $\alpha =.1$\pause 

Suppose our data for 18 workers is
\[
35, -67, 95, -73, 5, 50, 50, 53, -61, 68, 38, -22, -13, 17, -16, -31, 62, 95
\]\pause 
$\overline{x} = 15.833$.  $s = 53.251$.\pause 

$H_{0}: \mu =0$.  $H_{a}: \mu >0$.\pause 

$t = \frac{15.833-0}{53.251/\sqrt{18}} = 1.2615$.\pause 

$P (T \geq 1.2615)$ in the $t (17)$ distribution is between .15 and .1.\pause 
 
This fails to be significant.  So we do not reject the null hypothesis.

 