\documentstyle[bj,txfonts]{article}

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

\begin{document}

\begin{center}
\Large
36-617: Applied Linear Models\\
Fall 2020\\
HW04 -- Due Mon Sept 27, 11:59pm 
\end{center}

\begin{itemize}

\item Please turn the homework in, as a single pdf, online in GradeScope using the link provided on the HW04 assignment page on canvas.cmu.edu, 
under Assignments.  Upload \ul{\em one} file per person.  

\item This week we are discussing Ch 5 of Sheather.  Next week we will move on to Ch 6.

\item  There are four exercises below; each one has ``parts''.

\end{itemize}


\section*{Exercises}

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

\item Let $y = X\beta + \epsilon$, where $y=(y_1,\ldots, y_n)^T$ is an $n\times 1$ column vector, $X$ is an $n\times (p+1)$ matrix whose first column is all 1's, $\beta=(\beta_0,\ldots,\beta_p)^T$ is a $(p+1)\times 1$ column vector, and $\epsilon=(\epsilon_1,\ldots,\epsilon_n)^T \sim N(0,\sigma^2I)$ is an $n\times 1$ random column vector, following a multivariate Normal distribution with mean vector 0 and variance-covariance matrix $\sigma^2I$, where $I$ is the $n\times n$ identity matrix.
\begin{enumerate}\itemsep=0pt\parsep=0pt\parskip=0pt
\item Use properties of the hat matrix $H=X(X^TX)^{-1}X^T$ and the multivariate Normal distribution as discussed in class, to show
\[
			\hat e \sim N(0,(I-H)\sigma^2)
\]
\item Let $H$ be the hat matrix for the multivariate regression model $y=X\beta + \epsilon$ as in part (a), and let $H_1$ be the hat matrix for the intercept-only model $y=\beta_0  + \epsilon $. 
\begin{enumerate}
\item Show that the fitted values $\hat y $ for the intercept-only model is an $n\times 1$ column vector, all of whose entries are $\bar y$, that is, 
$$
			\hat y  = \left[\begin{array}{c} \hat y _1 \\ \vdots \\ \hat y _n\end{array}\right]
			= \left[\begin{array}{c} \bar y \\ \vdots \\ \bar y\end{array}\right]
			\eqno{(*)}
$$
(where the first ``='' is the definition of $\hat y $ and the second ``='' is what I want you to show).
\item Find a simple expression, in terms of (some or all of) $y$, $I$, $H$ and $H_1$, for the sample covariance
\[
    \mbox{Cov}(y,\hat y) = \frac1n {\sum}_{i=1}^n (y_i - \bar y)(\hat y_i - \bar y).
\]
{\em ({\bf Hint:} We can rewrite $\mbox{Cov}(y,\hat y) = \frac1n (y - \bar y)^T(\hat y - \bar y)$, where $\hat y$ is the column vector of fitted values from $y=X\beta + \epsilon$ and, abusing notation slightly, $\bar y$ is the column vector in $(*)$ above, i.e. the fitted values from the intercept-only model $y = \beta_0  + \epsilon $.)}
\item Continue along the lines of the calculations in part (ii) to show that the sample correlation between $y$ and $\hat y$ can be written as
\[
	    \mbox{Corr}(y,\hat y) = \sqrt{\frac{SS_{reg}}{SST}}
\] 
and hence $R^2$ for the regression model $y = X\beta + \epsilon$ really is the squared correlation between $y$ and $\hat y$:
\[
			R^2 = \mbox{Corr}(y,\hat y)^2~.
\]

\end{enumerate}
\item Show that $\hat e$ and $\hat y$ have sample correlation 0, and hence a scatter plot of $\hat e$ vs $\hat y$ should show no increasing or decreasing trend, when the model $y = X\beta + \epsilon$ is true.

\end{enumerate}

\clearpage

\item Sheather, Ch 5, pp. 146--147, \#1. 
\begin{enumerate}
\item Develop a regression model to predict LATE from BILL, as requested by Sheather.
\item Provide a summary of your final model, residual diagnostic plots, etc.  Indicate whether you think you have a good or bad model, and justify your answer from the summaries \& plots you have provided.
\item Is the advertising slogan ``Under 60 days or your money back!!!!'' a good idea?  please choose one of the answers below, elaborate and justify it:
\begin{itemize}
\item Yes!
\item No, but if you change the number of days from 60 to \rule{.25in}{.01in} days, then the agency won't lose money on most cases.
\item Can't really answer the question with the regression model I've created.
\end{itemize}
\end{enumerate}

\item Sheather, Ch 5, p. 147, \#2.

 
\item{} [Based on Gelman \& Hill (2009), p. 51, \#5]  The subfolder {\tt beauty} in the hw04 folder in the ``Files'' area for our course on canvas contains data from Hamermesh and Parker (2005) on student
evaluations of instructors’ beauty and teaching quality for several courses at the
University of Texas. The teaching evaluations were conducted at the end of the
semester, and the beauty judgments were made later, by six students who had
not attended the classes and were not aware of the course evaluations.  Various documents in the folder give background and some variable definitions (some variables are defined in the ``.log'' file there, others' definitions you will have to deduce from pdf's in the subfolder). 
\begin{enumerate}
\item Fit a regression model predicting {\tt courseevaluation} (average student evaluations) from {\tt btystdave} (the average of 6 standardized beauty ratings for each instructor) and {\tt female}.  Then fit the same model with the interaction between {\tt btystdave} and {\tt female} added in.
\begin{enumerate}
\item Graph each fitted model on a scatter plot of {\tt courseevaluation} vs {\tt btystdave}.  Indicate clearly in the graph what the various parameters in the model represent geometrically.
\item Display the four standard diagnostic plots in R and comment on their features, for each model. {\em N.b. the interpretation of these plots is exactly the same as it was for simple regression.}  Comment on whether the fit seems adequate from the evidence in these plots, for either model.  In case there are problems with the fit, indicate what they are and how you might improve things.
\item Produce summaries of the two fitted models; comment on the coefficient estimates and their standard errors, and on $R^2$, for each model  Use a partial $F$ test to determine whether the interaction should be kept. {\em Your comments should include not only technical points (``$B$'' in the ``$ABA^{-1}$'' metaphor for applied statistics from the course syllabus), but also what it means for understanding how factors may influence course evaluations (``$A^{-1}$'').}   
\end{enumerate}
\item Now what happens when you try to control for other variables by adding them to the better of these two models (no more interactions, just use additional main effects, for now)?  Find the best such model, and comment on its fit, and the interpretation of the estimated coefficients, using the same tools you used in part (a).  {\em Don't forget $A^{-1}$ from the ``$ABA^{-1}$'' metaphor.}

\end{enumerate}

\comment{

% \item Ch 5, p. 147, \#2.  OK problem but I want to have the students practice the DMR parts of an IDMRAD paper instead....

% \item Ch 5. pp. 147ff, \#3.  Kind of a dumb problem the way it is set up.... 

% \item From Gelman \& Hill, Ch 3, consider
% 
% -- \#5 p 54, the beauty data -- used above...
% 
% -- \#1, p 49, the pyth data -- kind of abstract the way it's set up...  also, no data seems to be available!  PROLLY GOOD WITH EFFORT -- used in hw03, 2020

\item An IDMRAD paper has the following sections:
\begin{description}
\item[Abstract] Summarize I, D, M R and D sections of the paper (typically one sentence each).
\item[Introduction] Why would anyone want to read this paper?  What questions will be addressed?
\item[Data] What data set was used in this study?  Typically, include variable definitions, sample size, quick numerical summaries of the variables and initial EDA, but {\em no model fitting or analysis}.
\item[Methods] List the methods and/or analyses that will be used to answer the questions stated in the {\bf Introduction}.  {\em No data analysis, graphing, model fitting, etc. appears here}; you just say what methods and analyses you will use with which variables, to answer each question. 
\item[Results] Here you {\em finally} get to show the data analyses (model fitting, graphics, etc.) that you did, and what the results were.  Don't overload the reader: put the highlights here so the reader understands what you did and why, and refer the reader to specific pages or sections of the technical appendix for more details.  It should be clear which data analyses and results go with which question from the {\bf Introduction}.  {\em Every analysis that is presented here should have been mentioned in the {\bf Methods} section.}
\item[Discussion] What does it all mean?  Typically you will say, for each question from the {\bf Introduction}, how the analyses that you did the {\bf Results} section answers that question.  You might also mention EDA and so forth from the {\bf Data} section if that makes clearer to the reader what answers you found for one (or more) of the questions.  Then you will talk about the big picture, what future work or generalizations of your work might look like, and any limitations of your study.  But {\em there should be no additional analyses or results in this section; just use the analyses you did for the {\bf Results} section (and possibly the {\bf Data} section).}
\item[References] All the works you relied on to write your paper, in ASA citation format (see the section entitled ``The Reference List'' in https://amstat.tfjournals.com/asa-style-guide/).
\item[Technical Appendix] This contains complete versions of the analyses listed in the {\bf Methods} section and presented in the {\bf Results} section.  There may be additional analyses here (e.g. to support the {\bf Data} section of the paper, or to show why the methods and analyses that you chose for the paper were the right ones).
\end{description}
Review the paper ``menu pricing IDMRAD - version 2 with appx.pdf'' in the week01 folder in the files area for our class on Canvas, to see an example of what goes in each section, and how the technical appendix is used to contain details that would be ``too much'' in the main sections the paper.\\

For this exercise, please write 
\begin{enumerate}
\item The {\bf Data} section
\item The {\bf Methods} section
\item The {\bf Results} section
\item The {\bf Technical Appendix}
\end{enumerate}
of an IDMRAD paper, based on your work with the {\tt cars04.dat} data from HW03.   For the   {\bf Technical Appendix}, use what you turned in for problems 1--4 on HW03.  To get you started on the other parts, here is an {\bf Introduction} for the paper.  Since I cited some sources in the introduction, I also include a {\bf Reference} section.

\begin{quote}

\subsection*{Introduction}

The automobile industry is a major segment of the US economy.  A part of understanding this segment of the economy is understanding the factors that influence the suggested retail price of autos in the US.  I have been asked to examine the variables in an extract of automobile data from The Kiplinger (2003); the particular extract was provided by Sheather (2009).  In particular the questions I will answer in this report are (a) What can we learn from descriptive statistics and exploratory data analysis of all of the variables in the Kiplinger data extract? (b) What is the best/most interpretable model that relates Dealer Cost to Suggested Retail Price in the data, ingoring all other variables?  (c) What does this model tell us (if anything) about the relationship between Dealer Cost and Suggested Retail Price?

\subsection*{References}

\begin{description}
\item
Sheather, S.J. (2009), {\em A Modern Approach to Regression with R.} New York: Springer Science + Business Media LLC.
\item
The Kiplinger (2003),  {\em Kiplinger's Personal Finance, December 2003, vol. 57, no. 12,} pp. 104--123.  New York: PARS International Corporation.  Accessed at http://www.kiplinger.com.

\end{description}

\end{quote}

}

\end{enumerate}


\end{document}
