\documentclass[12pt]{article}
\usepackage{latexsym}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage[reqno]{amsmath}
\usepackage{natbib}
\usepackage{verbatim}
\usepackage{url}
\usepackage{lscape}
%\usepackage{subfigure}
\usepackage{subcaption}
%\usepackage{fullpage}
\usepackage{setspace}
\usepackage{booktabs,array}
\addtolength{\oddsidemargin}{-.45in}
\addtolength{\evensidemargin}{-.45in}
\addtolength{\textwidth}{1.in}          %\addtolength{\textwidth}{1.45in}
\addtolength{\topmargin}{-.225in}
\addtolength{\textheight}{1.0in}
% === dcolumnpackage===
\usepackage{dcolumn}
\newcolumntype{.}{D{.}{.}{-1}}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\usepackage{setspace}
\usepackage{color,hyperref, longtable}
\usepackage{epstopdf}
\newcommand {\mabsingle} {\Large \renewcommand{\baselinestretch}{1} \normalsize}
\newcommand {\mabdouble} {\renewcommand{\baselinestretch}{2} \Large \normalsize}
\newcommand {\mabnote} {\Large \renewcommand{\baselinestretch}{1} \footnotesize \hspace{-.06in}}
\setlength{\textfloatsep}{6pt}
\setlength{\floatsep}{6pt}
\setlength{\intextsep}{6pt}
\usepackage[Glenn]{fncychap}    % Glenn or Lenny are best styles
\usepackage{fancybox}
\newenvironment{shadowminipage}%
{\begin{Sbox}\begin{minipage}}
{\end{minipage}\end{Sbox}\shadowbox{\TheSbox} }


\begin{document}
\mabsingle
%\begin{titlepage}
\title{Answer Key for Ch14 Exercise1: Derive $\hat{\beta}$ \vspace{0.0in}}
\maketitle
\vspace{-0.2in}
%\end{titlepage}

\begin{enumerate}
\item Apply the logic developed in this chapter to the model $Y_i = \beta_0 + \beta_1X_i + \epsilon_i$.  Derive the OLS estimate for $\hat{\beta}_0$ and $\hat{\beta}_1$.
    \begin{enumerate}
    \item Write out the sum of squared residuals for the model
    \begin{eqnarray*}
    \sum \hat{\epsilon}_i^2 & = & \sum (Y_i - \hat{\beta}_0 - \hat{\beta}_1 X_{i})^2
    \end{eqnarray*}
    \item We minimize the sum of squared residuals by taking the derivatives with respect to $\hat{\beta}_0$ (one equation) and $\hat{\beta}_1$ (a second equation) and setting them to zero.\footnote{\mabnote These are often referred to as ``normal equations'' (as if we haven't used the word \emph{normal} enough in statistics).}  The estimates are the values which produce a derivative of zero.
    \begin{eqnarray*}
    \frac{\partial \sum \hat{\epsilon}_i^2}{\partial \hat{\beta}_0} & = & (-2)\sum (Y_i - \hat{\beta}_0 - \hat{\beta}_1 X_{i}) = 0\\
    \frac{\partial \sum \hat{\epsilon}_i^2}{\partial \hat{\beta}_1} & = & (-2)\sum (Y_i - \hat{\beta}_0 - \hat{\beta}_1 X_{i})(X_i) = 0
    \end{eqnarray*}
    \item Solving for $\hat{\beta}_0$ is relatively straightforward.  Divide both sides by $(-2)$ and do the following steps:
        \begin{eqnarray*}
        \sum Y_i -  \sum \hat{\beta}_0 - \sum \hat{\beta}_1 X_{i})  &=& 0                   \mbox{ Separate the sum into components}\\
        \sum Y_i - \sum \hat{\beta}_1 X_{i})                        &=& \sum \hat{\beta}_0  \mbox{ Move $\hat{\beta}_0$ to RHS}\\
        \sum Y_i - \hat{\beta}_1 \sum X_{i})                        &=& N\hat{\beta}_0      \mbox{ Pull constants out of summations}\\
        \frac{\sum Y_i}{N} - \hat{\beta}_1 \frac{\sum X_{i}}{N}     &=& \hat{\beta}_0       \mbox{ Divide by $N$}\\
        \overline{Y} - \hat{\beta}_1 \overline{X}                   &=& \hat{\beta}_0       \mbox{ Use definition of mean}
        \end{eqnarray*}
    \item To solve for $\hat{\beta}_1$ divide both sides of the derivative with respect to $\hat{\beta}_1$ by $(-2)$ and do the following steps:
        \begin{eqnarray*}
        \sum Y_iX_i -  \sum \hat{\beta}_0 X_i - \sum \hat{\beta}_1 X_{i}^2                                  &=& 0    \mbox{ Separate the sum into components}\\
        \sum Y_iX_i -  \sum (\overline{Y} - \hat{\beta}_1 \overline{X})X_i - \sum \hat{\beta}_1 X_{i}^2     &=& 0    \mbox{ Substitute for $\hat{\beta}_0$}\\
        \sum Y_iX_i -  \sum \overline{Y}X_i                                                                 &=& \hat{\beta}_1 (\sum  X_{i}^2 -\overline{X}\sum X_i)   \mbox{ Simplify}\\
        \hat{\beta}_1                                                                                       &=& \frac{\sum Y_iX_i -  \sum \overline{Y}X_i}{\sum  X_{i}^2 -\overline{X}\sum X_i}  \mbox{ Solve for $\hat{\beta}_1$}
        \end{eqnarray*}
    \item We prefer the equation for $\hat{\beta}_1$ to be in the more intuitive mean-deviated form.
            \begin{enumerate}
            \item First substitute for $\sum X_i = N\overline{X}$.  Be careful to note that $\sum Y_iX_i$ cannot be simplified; we can only use this for terms where the only thing in the summation is $X$ or $X$ times a constant.
                \begin{eqnarray*} \hat{\beta}_1     &=& \frac{\sum Y_iX_i -  N\overline{Y}\overline{X}}{\sum  X_{i}^2 -N\overline{X}^2} \end{eqnarray*}
            \item Next use facts that $\sum X_i = N\overline{X}$ and $\sum Y_i = N\overline{Y}$ to rewrite $(Y_i - \overline{Y})(X_i-\overline{X})$, which is the form we are seeking for the numerator of the $\hat{\beta}_1$ equation.
                \begin{eqnarray*}
                \sum (Y_i - \overline{Y})(X_i-\overline{X}) &=& \sum Y_iX_i - \overline{X}\sum{Y_i}- \overline{Y}\sum X_i + N\overline{Y}\overline{X}               \\
                                                            &=& \sum Y_iX_i - N\overline{X}\overline{Y}- N\overline{Y}\overline{X} + N\overline{Y}\overline{X}      \\
                                                            &=& \sum Y_iX_i - N\overline{X}\overline{Y}
                \end{eqnarray*}
            which is the value we had in the numerator of $\hat{\beta}_1$ in part (d) above, meaning we can use $\sum (Y_i - \overline{Y})(X_i-\overline{X})$ in the numerator.
            \item Do similar steps for the denominator of the $\hat{\beta}_1$ equation.
                \begin{eqnarray*}
                \sum (X_i - \overline{X})(X_i-\overline{X}) &=& \sum X_i^2 - 2\overline{X}\sum{X_i} + N\overline{X}^2   \\
                                                            &=& \sum X_i^2 - 2N\overline{X}^2 + N\overline{X}^2         \\
                                                            &=& \sum X_i^2 - N\overline{X}^2
                \end{eqnarray*}
            which is the value we had in the denominator of $\hat{\beta}_1$ meaning we can use $\sum (X_i - \overline{X})^2$ in the denominator, meaning that
                \begin{eqnarray*}
                \hat{\beta}_1 &=& \frac{\sum (Y_i - \overline{Y})(X_i-\overline{X})}{\sum  (X_i - \overline{X})^2}
                \end{eqnarray*}
            \end{enumerate}
    \end{enumerate}
\end{enumerate}


\end{document}
