\documentstyle[bj,txfonts,11pt]{article}

\frenchspacing
\def\vtrim{\vspace*{-0.8em}}

\begin{document}

\begin{center}
\Large
36-617: Applied Linear Models\\
Fall 2018\\
HW01 -- Due Tue Sep 7, 11:59pm
\end{center}

\begin{itemize}\parsep=0pt\itemsep=0pt\parskip=0pt

\item Most HW will be due on Mondays at 11:59pm, but since Sep 6 is a holiday, this assignment is due the next day.

\item Please turn the homework in online to GradeScope in our course webspace at canvas.cmu.edu.  The easiest way to do this is to go to the Assignments area of our Canvas webspace, then click on HW01, then use the link there to submit to Gradescope. 
\begin{itemize}  
\item Please upload only \ul{\em one} file (pdf format ONLY) for each homework assignment.  If you are an RStudio user, the easiest way create a pdf file to submit is to make an RMarkdown file for your homework solutions, and then ``knit'' it to pdf. Other approaches such as making an MSWord file or \LaTeX{} file and converting it to pdf, or writing things out by hand and scanning to pdf with your phone, etc., are also acceptable.
\item If you need additional help with this, please see https://www.cmu.edu/teaching/gradescope/index.html.  Also, allow yourself some extra time to create the pdf \& upload it in Gradescope.
\item Gradescope allows the TA to grade all the problem 1's together, then all the problem 2's, and so forth.  This leads to more consistent grading and better comments for you.
\end{itemize}

\item Data files (where needed) for these exercises are in the ``0 - textbooks'' folder in the files area on canvas.

\item Reading:
\begin{itemize}

\item For this week, you should be reading Chapters 1 and 2 in Sheather.  

\item For next week, please take a look at the handouts in the week02 folder in the files area on canvas.

\item On Sep 13 we will resume with regression; for this see Chapter 3 of Sheather.

% \item We are skipping Sheather Ch 4 for now, and proceeding to Ch 5, for the following week (the week of Sept 21).

\end{itemize}

\item There are five exercises.\\[-2em]

\end{itemize}


\section*{Exercises}

\begin{enumerate}\itemsep=0pt\parsep=0pt\parskip=0pt

\item Sheather, Ch 2, p. 38, \#1

% \item Sheather, Ch 2, p. 39, \#3.  Be careful that you understand what units the data are in!

\item Sheather, Ch 2, pp. 41--42, \#5

\item Sheather, Ch 2, p. 42 \#6

\item{}[Gelman \& Hill (2007), Ch 3, \#3] In this exercise you will simulate two variables that are statistically independent
of each other to see what happens when we run a regression of one on the other.
\begin{enumerate}\itemsep=0pt\parsep=0pt\parskip=0pt
\item First generate 1000 data points from a normal distribution with mean 0 and
standard deviation 1 by typing \verb|var1 <- rnorm(1000,0,1)| in R. Generate
another variable in the same way (call it \verb|var2|). Run a regression of one
variable on the other. Is the slope coefficient statistically significant?
\item Now run a simulation repeating this process 100 times. This can be done
using a loop. From each simulation, save the $z$-score (the estimated coefficient
of \verb|var1| divided by its standard error). If the absolute value of the $z$-score
exceeds 2, the estimate is statistically significant. Here is code to perform the
simulation\footnote{We have initialized the vector of $z$-scores with missing values (\verb|NA|s). Another approach is to
start with \verb|z.scores <- numeric(length=100)|, which would initialize with a vector of zeroes.
In general, however, we prefer to initialize with \verb|NA|s, because then when there is a bug in the
code, it sometimes shows up as \verb|NA|s in the final results, alerting us to the problem}:
%\begin{minipage}{5in}
\begin{verbatim} 
z.scores <- rep (NA, 100)
for (k in 1:100) {
  var1 <- rnorm (1000,0,1)
  var2 <- rnorm (1000,0,1)
  fit <- lm (var2 ~ var1)
  z.scores[k] <- coef(fit)[2]/se.coef(fit)[2]
}
\end{verbatim}
%\end{minipage}

How many of these 100 $z$-scores are statistically significant?  
\item Is your answer to (b) what you expected?  Why or why not?  
\end{enumerate}

% \clearpage

\item Sheather, Ch 2, pp 42--43, \#7

\comment{

\item{} [Gelman \& Hill (2007), Ch 3, \#2] Suppose that, for a certain  population, we can predict log earnings from log
height as follows:
\begin{itemize}\itemsep=0pt\parsep=0pt\parskip=0pt
\item A person who is 66 inches tall is predicted to have earnings of \$30,000.
\item Every increase of 1\% in height corresponds to a predicted increase of 0.8\% in
earnings.
\item The earnings of approximately 95\% of people fall within a factor of 1.1 of
predicted values.
\end{itemize}
\begin{enumerate}\itemsep=0pt\parsep=0pt\parskip=0pt
\item Give the equation of the regression line and the residual standard deviation
of the regression.
\item Suppose the standard deviation of log heights is 5\% in this population. What,
then, is the $R^2$ of the regression model described here?
\end{enumerate}

}

\comment{

% \item Sheather, Ch 3, pp 109ff, \#5

\item Sheather, Ch 3, pp 112ff, \#8

\item In the folder for this hw assignment you will find a pdf called ``An IMRAD paper on wine.pdf'', based on Example 1.2.4 in Sheather.  This is another data analysis based only on EDA, not on any more sophisticated methods.
\begin{enumerate}

\item Does the paper appropriately address each of the parts of an IMRAD paper as described on slide 3, lecture 02 from week01 of class?  If you need more detail on the sections of an IMRAD paper, see \verb|http://www.jpgmonline.com/documents/author/24/2_Aggarwal_10.pdf|.\\[-1em]  

For each section below, either say ``yes this section has the right content'', or say ``no'' and describe what is missing and/or what needs to be moved to another section of the paper or deleted.
\begin{itemize}
\item Abstract
\item Introduction
\item Methods
\item Results
\item Discussion
\end{itemize}

\item As described on slide 5 of the same lecture, an IDMRAD paper is a bit different in that there is a {\bf Data} section between the {\bf Introduction} and the {\bf Methods} sections, devoted to a description of the data used in the paper.  \\[-1em] 

Please write the appropriate {\bf Data} and {\bf Methods} sections for this paper (just those two sections), as an IDMRAD paper instead of an IMRAD paper (include appropriate text, figures and tables in the two sections).  For your convenience the three figures and three tables of this paper are saved as jpg files in the folder for this assignment.

\end{enumerate}

}

\end{enumerate}


\end{document}
