\documentclass[landscape,17pt]{foils}
\usepackage{pause,color,latexsym,amssymb,amsfonts,graphicx}
\pagestyle{empty}%% You may want to alter this to put on page numbers
%\setlength{\textheight}{7in}
%\setlength{\textwidth}{6.5in}
%\setlength{\headheight}{0in}
%\setlength{\headsep}{0in}
%\setlength{\oddsidemargin}{0in}
%\setlength{\topmargin}{-1.0in}
%\setlength{\parindent}{2em}
\definecolor{purple}{rgb}{1,0,1}
\definecolor{darkblue}{rgb}{.10,.0,.55}
\definecolor{darkgreen}{rgb}{.1,.55,.1}
\newcommand{\red}[1]{\textcolor{red}{#1}}
\newcommand{\purple}[1]{\textcolor{purple}{#1}}
\newcommand{\blue}[1]{\textcolor{blue}{#1}}
\newcommand{\darkblue}[1]{\textcolor{darkblue}{#1}}
\newcommand{\darkgreen}[1]{\textcolor{darkgreen}{#1}}
\begin{document}






{\bf December 1, 2003, \red{\S 19: Comparing two population proportions}}


\noindent Homework: 18.30, 18.36, 19.8, 19.9, 19.12, 19.15. Due 12/5. \pause 


\noindent \textsc{Review of Chapter 18:  inference about a population proportion.}

\noindent \textsc{Example:}  What proportion of the population is
left-handed? 

Use the ``plus four''
confidence interval.  \pause   If we want a 95\% confidence interval,
take $z_{*} = 1.96$ so that $95\%$ of values under the standard normal
curve are between $-z_{*}$ and $z_{*}$. \pause Then take
\[
\overline{p} = \frac{\mbox{successes} + 2}{n+4} = \frac{13}{94} = .1383.\pause 
  \]
Then
$p$ is 
\[
\overline{p} \pm z_{*} \sqrt{\frac{\overline{p}
(1-\overline{p})}{n+4}} = .1383 \pm 1.96 \sqrt{.1383 (.8617)/94} =
.1383 \pm .0698
\]  with confidence 95\%. \pause 

Notice that this is a rather large interval.  It tells us with 95\%
confidence that there are \red{6.8\% to 20.8\%} left-handed people in the
population.  To get a better estimate, we would need a much larger
sample than our size of 90.

\newpage

\noindent \textsc{Example:} Hypothesis testing for one-sample
proportions.  



\begin{enumerate}
\item Our null hypothesis is $H_{0}:p=p_{0} (=.46)$.  In other words,
\purple{that the percent of people who get colds is unaffected by
taking vitamin C}.  Our alternative
hypothesis is $H_{a}:p<p_{0}=.46$.
\item Our $z$-statistic is 
\[
z = \frac{\hat{p}-p_{0}}{\sqrt{p_{0} (1-p_{0})/n}} =
\frac{.45-.46}{\sqrt{.46 (.54)/264}} = -.326.
\]\item Our $P$-value is 
\[
P (Z \leq -.326) = .3722.
\]
This is \purple{the probability (if vitamin C has no effect on the
probability of getting a cold) that we would see this number of colds
or fewer in our sample population.}
\item Conclusion:  We do not have enough evidence to reject the null
hypothesis.  

In English:  \purple{if vitamin C has no effect on the probability of getting
a cold, we would see this number of colds or fewer among our
volunteers 37\% of the time.  Since that is a high probability, we
have no evidence that vitamin C effects the probability of getting a cold.}
\end{enumerate}


\newpage

{\red{Let $X$ be some random variable of a large population which
has values SUCCESS and FAILURE.  Take an SRS of size $n$ from our population, and
let $\hat{p}$ be the proportion of the sample which is ``SUCCESS.''
So 
\[
\hat{p} = \frac{\mbox{number of successes in a sample}}{\mbox{total
size of sample}}
\]
\pause 
\begin{itemize}
\item For large $n$, the sampling distribution of $\hat{p}$ is approximately
normal;  $N (p,\sigma )$ where \pause 
\item $p$ is the proportion of the entire population which is
``SUCCESS'' and  \pause 
\item 
\[
\sigma = \sqrt{\frac{p (1-p)}{n}}.
\]
\end{itemize}
}}
\pause 

\newpage

\noindent \textsc{\darkgreen{\S 19: Comparing two proportions}}

We consider a situation where we wish to compare two proportions.
Typically we would like to compare the effect of two different
treatments,  either in an experiment or in an observation.  

We assume we have two populations:

\begin{tabular}{|l|l|l|l|}
\hline
Population & Proportion &  Sample Size & Sample proportion \\
\hline
1 & $p_{1}$ & $n_{1}$ & $\hat{p}_{1}$    \\
2  & $p_{2}$ & $n_{2}$ & $\hat{p}_{2}$   \\
\hline
\end{tabular}\pause

We'd like to use $\hat{p}_{1}-\hat{p}_{2}$ to estimate $p_{1}-p_{2}$.
The critical observations are the following:\begin{itemize}
\item if $n_{1}$ and $n_{2}$ are large enough, the distribution of
$\hat{p}_{1}-\hat{p}_{2}$ is approximately normal, 
\item with mean $p_{1}-p_{2}$
\item and standard deviation 
\[
\sqrt{\frac{p_{1} (1-p_{1})}{n_{1}}+ \frac{p_{2} (1-p_{2})}{n_{2}}}.
\]
\end{itemize}

To estimate confidence intervals, we could proceed as usual, using for our
error term
\[
SE = \sqrt{\frac{\hat{p}_{1} (1-\hat{p}_{1})}{n_{1}}+
\frac{\hat{p}_{2} (1-\hat{p}_{2})}{n_{2}}}
\]
It turns out that we get more accurate results by using the ``Plus 4''
confidence estimates (adding 4 imaginary observations - 2 to our first
sample, and two to our second sample).  So we replace $n_{1}$ above
with $n_{1}+2$, replace $n_{2}$ with $n_{2}+2$.  $\hat{p}_{1}$ with
$\overline{p}_{1}$ (where we add two observations, one success and one
failure) and similary, $\hat{p}_{2}$ with $\overline{p}_{2}$.  So we
get 
\[
SE = \sqrt{\frac{\overline{p}_{1} (1-\overline{p}_{1})}{n_{1}+2}+
\frac{\overline{p}_{2} (1-\overline{p}_{2})}{n_{2}+2}}.
\]
Then if $z_{*}$ is a critical value for confidence level $C$, we get
$p_{1}-p_{2}$ is 
\[
\overline{p}_{1}-\overline{p}_{2} \pm z_{*}SE
\]
with confidence $C$.

\newpage


\noindent \textsc{Example:} Problem 19.3.  Note that a ``success'' in
this problem is a positive drug test result.  

\begin{tabular}{|l|l|l|l|}
\hline
Population & Proportion &  Sample Size & Sample proportion \\
\hline
Tested athletes & $p_{1}$ & $135$ & $\overline{p}_{1} = \frac{8}{137}
= .0584$    \\
Untested athletes  & $p_{2}$ & $141$ & $\overline{p}_{2} =
\frac{28}{143} = .196$   \\
\hline
\end{tabular}\pause

Then $p_{1}-p_{2}$ is 
\[
.0584 - .196 \pm 1.96 \sqrt{\frac{.0584 (1-.0584)}{137} + \frac{.196
(1-.196)}{143}} =\]\pause 
$-.1374 \pm 1.96 .0388 = -.1374 \pm .076$
with 95\% confidence. \pause 

So if these samples were random,  we have $p_{1}-p_{2}$ is between
$-.0614$ and $-.2134$ with 95\% confidence.

\newpage

\noindent \textsc{Example:}  Hypothesis testing for two-sample proportions

\noindent A study in Britain (published in \emph{The Lancet}) examined
120,633 women pregnant with their second child.  Of the 17,754 who had
delivered their first child by Ceasarean section, there were 68
stillbirths before labor.  Of the remaining 102,879, there were 244
stillbirths before labor.\pause 

\purple{We wish to know if this is evidence that a Ceasarean section increases
the likelihood of a stillbirth in the next pregnancy. }\pause 

\begin{tabular}{|l|l|l|l|}
\hline
Population & Proportion &  Sample Size & Sample proportion \\
\hline
C-section & $p_{1}$ & $17,754$ & $\hat{p}_{1} = \frac{68}{17,754} = .00383$   \\
no C-section  & $p_{2}$ & $102,879$ & $\hat{p}_{2}=\frac{244}{102,879}
= .00237$   \\
\hline
\end{tabular}\pause

In addition to the numbers above, we'll need a number called the
\red{pooled sample proportion}.  This is 
\[
\hat{p} = \frac{68+244}{17,754+102,879} = .00259
\]\pause 

\begin{enumerate}
\item Our null hypothesis is that \purple{having a C-section does not affect
later possibility of stillbirth.}  So $H_{0}: p_{1}=p_{2}$.\pause 

Our alternative hypothesis is $H_{a}:p_{1}>p_{2}$.  (\purple{That C-sections
are associated with higher rates of stillbirths in the subsequent pregnancy.})\pause 
\item We calculate a two sample $z$-statistic as follows:
\[
z = \frac{\hat{p}_{1}-\hat{p}_{2}}{\sqrt{\hat{p} (1-\hat{p})
(\frac{1}{n_{1}}+ \frac{1}{n_{2}})}}\pause  = \frac{.00383-.00237}{.00237
(1-.00237) (\frac{1}{17,754}+ \frac{1}{102,879})} = 3.535.
\]\pause 
\item We now calculate our $P$-value.  We calculate $P (Z \geq
3.535)$.  This is \purple{the probability} (if $H_{0}$ is true - that is
\purple{if C-sections are not associated with higher rates of stillbirth in
the subsequent pregnancy) that we would see at least this many more
stillbirths in the C-section population.}
\[
P (Z \geq 3.535) = .0002
\]\pause 
\item Conclusion:  If $H_{0}$ is true, then the chance of results like
the ones we see is $.0002$.   This is strong evidence against $H_{0}$.\pause 

In words:  \purple{if $C$-sections are not associated with higher rates of
stillbirth, then the probability of a result like the one we've seen
is $.0002$.  We consider this strong evidence that $C$-sections
\emph{are} associated with higher rates of stillbirth.}\pause 
\end{enumerate}

\noindent NOTE:  this method is approriate if \begin{itemize}\pause 
\item The populations are at least 10 times as large as the samples.\pause 
\item There are at least 5 failures and at least 5 successes in each sample.
\end{itemize}






\end{document}
