\documentclass[twocolumn]{article}

\setlength{\oddsidemargin}{-0.5in}
\setlength{\evensidemargin}{-0.5in}
\setlength{\topmargin}{0.0in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\setlength{\textwidth}{7.0in}
\setlength{\textheight}{9.5in}
\setlength{\parindent}{0in}
\setlength{\parskip}{0.05in}
\setlength{\columnseprule}{0.3pt}

\setlength\columnsep{25pt}

\usepackage{fancyvrb}
\usepackage{relsize}
\usepackage{hyperref}

\usepackage{listings}
\usepackage{amsmath}

\begin{document}

\lstset{xleftmargin=5mm,framexleftmargin=10mm,basicstyle=\footnotesize}

Name: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

Directions: {\bf \Large Work only on this sheet} (on both sides, if
needed).  MAKE SURE TO COPY YOUR ANSWERS TO A SEPARATE SHEET FOR SENDING
ME AN ELECTRONIC COPY LATER.

{\bf Important note:}  Remember that in problems calling for R code, you
are allowed to use any built-in R function, e.g. {\bf choose()}, {\bf
sum()}, etc.  

{\bf 1.} The following R function forms a confidence interval for a
population proportion, based on the sample in the vector {\bf x}, of
approximate confidence level {\bf conflevel}.  

\begin{lstlisting}
pci <- function(x,conflevel) {
      n <- __________(x)  # blank (a)
      p_hat <- __________(x)  # blank (b)
      stderr <- __________   # blank (c)
      multiplier <- _________   # blank (d)
      # in R, last value computed is returned
      c(__________)  # blank (e)
}
\end{lstlisting}

For instance, if our sample data is 1, 0, 0, and 1, and we want an
approximate 95\% confidence level, the call would be

\begin{lstlisting}
pci(c(1,0,0,1), 0.95)
\end{lstlisting}

\begin{itemize}

\item [(a)] (10) Fill in blank (a).

\item [(b)] (10) Fill in blank (b).

\item [(c)] (10) Fill in blank (c).

\item [(d)] (10) Fill in blank (d).

\item [(e)] (10) Fill in blank (e).

\end{itemize}

{\bf 2.}  There is the concept of the {\it power} of a hypothesis test,
defined to be the probability of rejecting $H_0$ in a circumstance in
which $H_0$ is false.  For instance, consider the coin example in
pp.221ff.  The power of the test at 0.55 is defined to be the
probability that we reject $H_0$ if the true value of p is 0.55.

\begin{itemize}

\item [(a)] (15) Power plays a big role in theoretical statistics, where
theorems are proved for things such as Uniformly Most Powerful tests.
But in practice, we may wish the power to be \underline{low}, not high,
in some settings.  Fill in the blank:  In the coin problem, for example,
we may wish to have low power in the setting in which p
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.

\item [(b)] (10) Consider the light bulb lifetime problem in pp.226-227.  Find
the power of the test for the case $\mu = 1250$.

\end{itemize}

{\bf 3.} (15) Suppose we have two population values to estimate, $\omega$
and $\gamma$, and that we are also interested in the quantity $\omega +
2 \gamma$.  We'll estimate the latter with $\hat{\omega} + 2
\hat{\gamma}$.  Suppose the standard errors of $\hat{\omega}$ and
$\hat{\gamma}$ turn out to be 3.2 and 8.8, respectively.  Find the
standard error of $\hat{\omega} + 2 \hat{\gamma}$.

{\bf 4.} (10) A news report tells us that in a poll, 54\% of those polled
supported Candidate A, with a 2.2\% margin of error.  Assuming that a
95\% level of confidence was used, find the approximate number polled.

{\bf Solutions:}

{\bf 1.a-e}

\begin{lstlisting}
pci <- function(x,conflevel) {
      n <- length(x)
      p_hat <- mean(x)
      stderr <- sqrt(phat * (1-phat) / n)
      multiplier <- qnorm(0.5 + conflevel / 2)
      # in R, last value computed is returned
      c(phat - multiplier*stderr, phat + multiplier*stderr)
}
\end{lstlisting}

{\bf 2.a} is near 0.5

{\bf 2.b} 

\begin{lstlisting}
1 - pgamma(15705.22,10,1/1250)
\end{lstlisting}

{\bf 3.}

$$
\sqrt{1^2 \cdot 3.2^2 + 2^2 \cdot 8.8^2}
$$

{\bf 4.}

\begin{lstlisting}
0.54 * 0.46 / (0.022/1.96)^2
\end{lstlisting}

\end{document}
