\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.} Consider the OOP study described at the top of p.281, which was
actually a bit different from the description in our book:\footnote{They
also used logarithms, but we'll ignore that here.}  

\begin{equation}
\label{oop}
\textrm{mean } Y =
\beta_0 + 
\beta_1 X^{(1)} +
\beta_2 X^{(2)} +
\beta_3 X^{(1)} X^{(2)}
\end{equation}

The results were:

\begin{tabular}{|r|r|r|r|}
\hline
coef. & betahat & std.err. \\ \hline 
$\beta_0$ & 4.37 & 0.23 \\ \hline 
$\beta_1$ & 0.49 & 0.07 \\ \hline 
$\beta_2$ & 0.56 & 1.57 \\ \hline 
$\beta_3$ & -0.13 & -1.34 \\ \hline 
\end{tabular}

\begin{itemize}

\item [(a)] (10) The last term in (\ref{oop}) is known as the 
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ term.

\item [(b)] (20) Find the estimated difference in mean completion time
under OOP and using procedure language  (former minus the latter), for
1000-line programs.

\item [(c)] (15) Find an approximate 95\% confidence interval for
$\beta_1$, answering with R's {\bf c()} form.

\item [(d)] (15) Find $\widehat{Var}(\hat{\beta}_0)$.

\end{itemize}

{\bf 2.} (15) In the marbles example, p.147, find $m_{Y;B}(2)$.

{\bf 3.} The code below estimates the regression function $m_{Y;X}(t)$
for scalar X, without assuming a linear or other parametric model.  The
vector parameters {\bf y}, {\bf x}, and the scalar parameter {\bf t}, 
are self-explanatory.  As to the scalar parameter {\bf h}, I'll 
simply say that we consider one number u ``near'' another number v if 
$|u-v| < h$. 

\begin{lstlisting}
nonparregest <- function(y,x,t,h) {
   dists <- blank (a)
   xnear <- blank (b)
   blank (c) 
}
\end{lstlisting}

\begin{itemize}

\item [(5)] Fill blank (a).

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

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

\end{itemize}

{\bf Solutions:}

{\bf 1.a} interaction

{\bf 1.b} 

\begin{lstlisting}
(4.37 + 0.49*1000 + 0.56*1 - 0.13*1000*1) -
(4.37 + 0.49*1000 + 0.56*0 - 0.13*1000*0) 
\end{lstlisting}

{\bf 1.c}

\begin{lstlisting}
c(0.49 - 1.96 * 0.07, 0.49 + 1.96 * 0.07)
\end{lstlisting}

{\bf 1.d}

\begin{lstlisting}
0.23 ^ 2
\end{lstlisting}

{\bf 2.}

\begin{lstlisting}
(0.036*0 + 0.048*1 + 0.006*2) / (0.036 + 0.048 + 0.006)
\end{lstlisting}

{\bf 3.}

\begin{lstlisting}
nonparregest <- function(y,x,t,h) {
   dists <- abs(x-t)
   xnear <- which(dists < h)
   mean(y[xnear])
}
\end{lstlisting}

\end{document}

