\documentstyle[11pt,bj]{article}

\begin{document}

\frenchspacing

\input info.tex

\def\title{Homework 2}
\def\due{Thursday, September 13, 2001}

\pagestyle{myheadings}
\markboth{\title}{\title}
\makeatletter
%\def\@oddhead{\hbox{}\bf\leftmark \hfil \rightmark}
\def\@oddhead{\bf\rightmark\hfil} %\rm\thepage}
\let\@evenhead\@oddhead
\newsavebox{\datebox}
\savebox{\datebox}{\llap{\term}{}}
\def\@oddfoot{\class\hfil\usebox{\datebox}}
\let\@evenfoot\@oddfoot
\makeatother

\begin{center}\large\bf
\title\\ 
Due: \due \\
\end{center}

%\begin{problist}

\begin{enumerate}

\item Reading.  
\begin{itemize}
\item In RPD (the Rawlings, Pantula and Dickey regression text) you
  should read through all of chapter 1, on simple regression.

\item Work through the two Splus tutorials
\begin{itemize}
\item Objects: `Objects and Data Types in Splus''
\item Programming: ``Programming in Splus''
\end{itemize}
available in many places, for example, at  {\tt
  http://www.stat.cmu.edu/\~{}brian/707/S-Tutorial}.    You do not
  have to hand anything in for this question.

\end{itemize}

\item RPD, p. 30,  Ex. 1.3.

% \item RPD, p. 32, Ex. 1.18.  Also, show that $\sum X_i e_i = 0$, when the
%   simple linear regression equation includes the constant term $\beta_0$.

\item 
\begin{enumerate}
\item Show that $\sum \hat Y_i e_i = 0$, where $e_i = Y_i - \hat Y_i$.
\item Show that $\sum Y_i = \sum \hat Y_i$.
\item Use parts (a) and (b) to prove the ANOVA decomposition of the
total sum of squares, $S_{YY}$.  That is, demonstrate that
$S_{YY} = SS_{Reg} + RSS$. 
\end{enumerate}

\item 
\begin{enumerate}
\item Show that $\hat\beta_1 = r_{XY}\cdot\frac{S_Y}{S_X}$, where 
where $r_{XY}$ is the sample correlation between the $X$'s and the
$Y$'s, $S_Y^2$ is the sample variance of the $Y$'s and $S_X^2$ is the
sample variance of the $X$'s.  
\item Recall that $SS_{Reg}= \sum (\hat Y_i - \bar Y)^2 =
  \sum(\hat\beta_0 + \hat\beta_1 X_i - \bar Y)^2$.  From this, show
  that $SS_{Reg} = \hat\beta_1^2\sum (X_i - \bar X)^2$, and therefore
  $R^2=SS_{Reg}/SYY$ is equal to $(r_{XY})^2$.
\end{enumerate}
% \item We showed that the least-squares slope for the regression of Y
% on X is $B_{Y|X} = SXY/SXX = \sum_i(X_i-\bar X)(Y_i-\bar
% Y)/\sum_i(X_i-\bar X)^2$; show that this can also be written as
% \[
%         B_{Y|X} = r_{XY} \frac{S_Y}{S_X}
% \]
% where $r_{XY}$ is the sample correlation between the $X$'s and the
% $Y$'s, $S_Y^2$ is the sample variance of the $Y$'s and $S_X^2$ is the
% sample variance of the $X$'s.  


\item [The] {\tt Angell.dat} data set that we used last week came from a
  study by Angell (1951) on 43 US cities.  The variables collected were:
\begin{itemize}
\item {\tt Moral}: An index of ``moral'' or social integration,
  combining information on on the incidence of crime with data on
  social welfare expenditures.
\item {\tt Ethnic}: An index of ethnic heterogeneity, calculated from
  the proportions of nonwhites and foreign-born whites residing in the
  cities.
\item {\tt Geog}: An index of geographic mobility, constructed from
  the proportions of residents moving into and out of the cities.  
\item {\tt Region}: Region of the US where the city is: (E)ast,
  (S)outh, (W)est, or (M)id(W)est.
\end{itemize}
Angell argues that the moral integration of cities should decrease
with ethnic heterogeneity and geographic mobility.  In the next
several problems we briefly explore the relationship between {\tt
  Moral} and {\tt Ethnic}.

\clearpage

\item\label{angellreg} Regress {\tt Moral} on {\tt Ethnic}.
\begin{enumerate}
\item Plot the
  least-squares regression line on a scatterplot of the data, and
  comment on the results.  Examine and interpret the values of
  $\hat\beta_0$, $\hat\beta_1$, $s = \sqrt{RSS/(n-2)}$, and $r_{XY}$
  (or $R^2$).  You can use commands like
\begin{verbatim}
myfit _ lm(Moral ~ Ethnic, data = angell)
summary(myfit)
plot(angell$Ethnic,angell$Moral)
abline(myfit)
\end{verbatim}
  
\item Examine and comment on the residuals for the regression of
  {\tt Moral} on {\tt Ethnic} (the residuals should be approximately
  normally distributed, without patterns, outliers, etc.).  You can
  use commands like
\begin{verbatim}
plot(angell$Ethnic,residuals(myfit))
abline(h=0) # or abline(0,0)
qqenv(residuals(myfit))
\end{verbatim}
  or examine the first plot in each row of {\tt par(mfrow=c(2,3));
    plot(myfit)}.  We don't know how to interpret the other diagnostic
  plots here yet, but you can learn a little more about them by
  consulting {\tt help(plot.lm)}.
\end{enumerate}

\item\label{angellxform} Examine {\tt Ethnic}, and various simple
  transformations of it, with a histogram and quantile-normal plot.
  Among the variables {\tt Ethnic}, {\tt sqrt(Ethnic)} and {\tt
    log(Ethnic)}, which exhibits the best symmetry or normality
  properties?  {\em Note: The $X$ variable does not have to be
    normally distributed in a regression analysis, but skewing in
    either $X$ or $Y$ may suggest a transformation that improves the
    regression model.}

\item Re-do problem \#\ref{angellreg} using
  the best transformation you found in \#\ref{angellxform}.

   Note: suppose your transformed {\tt Ethnic} variable is called {\tt
   NewEthnic}.  Then you can make either of two plots comparing the
   regression line to the data:
\begin{verbatim}
plot(NewEthnic,Moral)
abline(lm(Moral ~ NewEthnic))
\end{verbatim}
or
\begin{verbatim}
plot(Ethnic,Moral)
lines(sort(Ethnic),fitted(lm(Moral ~ NewEthnic))[order(Ethnic)])
\end{verbatim}
Which do you prefer  for examining the regression?
Which do you prefer for communicating your results to a
non-statistical collaborator?  A similar decision arises for examining
the residuals from this regression.


\end{enumerate}

\end{document}


\item {\bf Writing exercise} Write a short (no more than two
  paragraphs) explanation of transformations of data, for a
  scientifically--literate reader.  You should assume that your reader
  is {\bf not} a statistician or mathematician; avoiding technical
  jargon is therefore important.  Cover what {\it you} consider to be
  the important points, while conveying enough information to the
  reader that she can gain an understanding of data transforming and
  its usefulness in data analysis.
  




%\end{problist}

\end{document}






