% This is a simple LaTex sample document that gives a submission format
%   for IEEE PAMI-TC conference submissions.  Use at your own risk.

% Make two column format for LaTex 2e.
\documentclass[11pt,twocolumn]{article} %
\usepackage[dvips]{graphicx,graphics,color}
\usepackage{times,amsmath,amsfonts}

\setlength{\textheight}{10in} \setlength{\textwidth}{6.875in}
\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{-0.5in}
\setlength{\headheight}{0in} \setlength{\headsep}{0in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.2in}  % Centers text.
\setlength{\evensidemargin}{-.2in}

% Add the period after section numbers.  Adjust spacing.

\newcommand{\bqn}{\begin{eqnarray}}
\newcommand{\eqn}{\end{eqnarray}}
\newcommand{\bq}{\begin{eqnarray*}}
\newcommand{\eq}{\end{eqnarray*}}
\begin{document}


% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 324: Lecture 16\\
Confidence Intervals}

% For single author (just remove % characters)
\author{Moo K. Chung\\
mchung@stat.wisc.edu}
\date{March 29, 2005}
\maketitle \thispagestyle{empty}
\begin{enumerate}

\section*{Concepts}

\begin{enumrate}




\item {\em Example (variance known).} The fat content of a hotdog is assumed
to follow $N(\mu,4^2)$. We randomly select 10 hotdogs:
\begin{verbatim}
> x<-c(25.2,21.3,22.8,17.0,29.8,
21.0,25.5,16.0,20.9,19.5)
> mean(x)
[1] 21.9
\end{verbatim}
We are interested in estimating the mean fat content. We can
estimate $\mu$ with the sample mean $\bar X=21.9$. The point
estimate does not provide the precision of the estimation.
Alternately, we will report an entire interval of possible values
$(\hat \mu_L, \hat \mu_U)$ that contains possible values of $\mu$.

%We are interested in constructing a 95$\%$ CI for the population
%mean fat content. Since the sample size is small, we can not apply
%large sample size results. Let us check the normality of data first
%using {\tt qqnorm(x)}.
%\begin{figure}[h]
%\centering
%\includegraphics[width=70mm]{324.16.01.ps}
%\caption{QQ plot showing normality of fat content.}\label{fig:sq}
%\end{figure}

\item A {\em confidence interval} (CI) is an interval used to estimate
the likely size of a population parameter. A {\em confidence level}
is a measure of the degree of reliability of the confidence
interval. Most commonly used confidence levels are the 90$\%$,
95$\%$ and 99$\%$ confidence intervals that have 0.90, 0.95 and 0.99
probabilities respectively of containing the parameter. For
population parameter $\mu$, 95$\%$ confidence interval $(\hat
\mu_L,\hat \mu_U)$ of $\mu$ is an interval that satisfies
$$P( \hat \mu_L \leq \mu \leq \hat \mu_U)=0.95.$$
We usually make the interval centered so that
$$P( \hat \mu_L \leq \mu) = P(\mu \leq \hat \mu_U)=0.025.$$

\item  If $X_i \sim N(\mu,\sigma^2)$ with known $\sigma^2$ and unknown $\mu$. $100(1-\alpha)\%$ confidence interval for $\mu$ is.
$$\hat \mu_L =\bar x - z_{\alpha/2} \cdot \sigma/\sqrt{n},\; \hat \mu_U=\bar x + z_{\alpha/2} \cdot \sigma/\sqrt{n},$$
where quantile $z_{\alpha/2}$ is given by $P\big(Z >
z_{\alpha/2}\big) = \alpha/2.$ For instance, a 95$\%$ {\em
confidence interval} for $\mu$ is $$\hat \mu_L =\bar x - 1.96 \cdot
\sigma/\sqrt{n},\; \hat \mu_U=\bar x + 1.96 \cdot \sigma/\sqrt{n}.$$

\item A $95\%$ confidence interval can be interpreted probabilistically
as an interval that can contain true unknown parameter $95\%$ of
time in the long run.


%The following simulation demonstrates this.\\
%Let $X_i \sim N(\mu,14^2)$. Suppose $\mu=42$ but assume we do not
%know this fact. Let $n=10$. This is the binge drinking example of
%Lecture 1.
%\begin{verbatim}
%> b=1.96*14/sqrt(10)
%> b
%[1] 8.67729
%
%> a1<-rnorm(10,42,14)
%> a1
%  [1] 72.97298 39.29226 48.76871 52.01553 50.07126 46.61409 28.11466 32.81800
%> c(mean(a1)-b,mean(a1)+b)
%[1] 38.63614 55.99072
%
%>  a2<-rnorm(10,42,14)
%> c(mean(a2)-b,mean(a2)+b)
%[1] 30.18341 47.53799
%
%> c(mean(a3)-b,mean(a3)+b)
%[1] 32.18435 49.53893
%
%>  a4<-rnorm(10,42,14)
%> c(mean(a4)-b,mean(a4)+b)
%[1] 40.65048 58.00506
%
%... If you this many many times .....
%
%>  a17<-rnorm(10,42,14)
%> c(mean(a17)-b,mean(a17)+b)
%[1] 45.15059 62.50517



\item {\em Example (variance unknown).} Reconsider the hotdog
example. Assume the fat content of a hotdog is assumed to follow
$N(\mu,\sigma^2)$ with unknown $\sigma$. We are interested in
constructing a $95\%$ confidence interval for $\mu$.

\item $$T = \frac{\bar X -\mu}{S/\sqrt{n}} \sim t_{n-1},$$
a t distribution with $n-1$ degrees of freedom. As $n \to \infty$,
$t_{n} \to N(0,1)$. $t$ distributions have thicker tails than the
standard normal distribution. For large sample size $n$, we can
approximate $t$ distribution with $N(0,1)$.


\item Critical value $t_{\alpha,n-1}$ is defined as the point that gives
$P(T > t_{\alpha,n-1}) = \alpha$. We can construct CI based on
$$P(-t_{\alpha/2,n-1} < T < t_{\alpha/2,n-1})=1-\alpha.$$
$100(1-\alpha)\%$ CI for $\mu$ is
$$\bar x \pm t_{\alpha/2}\frac{s}{\sqrt{n-1}}.$$

\begin{verbatim}
> qt(1-0.025,9)
[1] 2.262157
> sd(x)
[1] 4.13414
\end{verbatim}


\item {\em General large sample confidence interval.} Suppose $\hat
\theta$ is an unbiased estimator of some parameter $\theta$, Then
$100(1-\alpha)\%$ confidence interval is
$$\hat \theta + z_{\alpha/2}\sqrt{\mathbb{V} \hat \theta}.$$
In many applications, $\mathbb{V} {\hat \theta}$ is a function of
$\theta$ which makes computation of CI complicated. In this
situation, we need to estimate $\mathbb{V} {\hat \theta}$ further.

The following is a special case. Let $X_1,\cdots,X_n$ be a random
sample with mean $\mu$. For sufficiently large $n$,
$$Z=\frac{\bar X-\mu}{S /\sqrt{n}} \sim N(0,1)$$
where $S$ is the sample standard deviation. If $n$ is sufficiently
large, approximate $100(1-\alpha)\%$ confidence interval for $\mu$
is
$$\bar x \pm z_{\alpha/2}\frac{s}{\sqrt{n}},$$ where $s$ is the sample standard deviation.


\end{enumerate}


\section*{Problem}

A person tossed $n=100$ biased coins with $P(H)=p$ and observed 38
heads. Construct a 95$\%$ CI for $p$.

\begin{verbatim}
> X<-rbinom(100,1,0.4)
> X
  [1] 1 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0
 [17] 0 0 1 1 0 1 0 1 1 0 1 0 1 0 1 0
 [33] 1 1 0 0 0 0 1 0 1 0 0 0 0 0 1 0
 [49] 0 1 0 0 0 0 1 1 0 1 0 1 1 0 0 1
 [65] 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0
 [81] 1 0 1 0 0 1 1 0 0 0 1 0 0 1 1 1
 [97] 0 1 1 0
> sqrt(0.38*(1-0.38)/100)*1.96
[1] 0.09513574
> 0.38+0.095
[1] 0.475
> 0.38-0.095
[1] 0.285

\end{verbatim}
\begin{enumrate}
\end{enumerate}
{\bf Assigned problems.} Exercise 7. 6. part (a) only, 7.20, 7.32.
HW 5 due April 14th. Solve the assigned problems in Lecture 15-18.



\end{document}
