\documentclass[]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\hypersetup{unicode=true,
            pdftitle={Homework 08 Solutions},
            pdfborder={0 0 0},
            breaklinks=true}
\urlstyle{same}  % don't use monospace font for urls
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{248,248,248}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\ImportTok}[1]{#1}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}}
\newcommand{\BuiltInTok}[1]{#1}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}
\usepackage{longtable,booktabs}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi

%%% Use protect on footnotes to avoid problems with footnotes in titles
\let\rmarkdownfootnote\footnote%
\def\footnote{\protect\rmarkdownfootnote}

%%% Change title format to be more compact
\usepackage{titling}

% Create subtitle command for use in maketitle
\providecommand{\subtitle}[1]{
  \posttitle{
    \begin{center}\large#1\end{center}
    }
}

\setlength{\droptitle}{-2em}

  \title{Homework 08 Solutions}
    \pretitle{\vspace{\droptitle}\centering\huge}
  \posttitle{\par}
    \author{}
    \preauthor{}\postauthor{}
      \predate{\centering\large\emph}
  \postdate{\par}
    \date{11/21/2019}

\usepackage{amsmath}
\usepackage{amsthm}
\DeclareMathOperator{\Cov}{Cov}
\DeclareMathOperator{\Corr}{Corr}

\begin{document}
\maketitle

\section{2 (a)}\label{a}

We first fit a model regression Sales on all of the covariates except
Advert and Lag1Advert.

\begin{longtable}[]{@{}ccccc@{}}
\toprule
\begin{minipage}[b]{0.21\columnwidth}\centering\strut
~\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering\strut
Estimate\strut
\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\centering\strut
Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering\strut
t value\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering\strut
Pr(\textgreater{}\textbar{}t\textbar{})\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{(Intercept)}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
350.4\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
25.98\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
13.48\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
2.69e-22\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Time}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.4298\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
0.2381\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
1.805\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.07485\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_2}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
-18.4\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
31.81\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
-0.5785\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.5645\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_3}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
77.54\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
31.8\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
2.438\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.01698\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_4}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
101.9\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
31.8\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
3.203\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.001951\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_5}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
93.43\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
31.79\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
2.939\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.004306\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_6}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
89.75\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
31.79\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
2.823\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.005999\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_7}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
24.82\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
31.79\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
0.7808\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.4372\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_8}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
89.02\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
31.79\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
2.8\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.006403\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_9}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
166.8\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
31.79\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
5.247\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
1.236e-06\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_10}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
199.7\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
31.8\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
6.279\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
1.658e-08\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_11}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
374.3\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
32.84\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
11.4\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
1.954e-18\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_12}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
1151\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
32.83\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
35.05\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
2.62e-50\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

\begin{longtable}[]{@{}cccc@{}}
\caption{Problem 2a: Summary of ordinary linear model.}\tabularnewline
\toprule
\begin{minipage}[b]{0.18\columnwidth}\centering\strut
Observations\strut
\end{minipage} & \begin{minipage}[b]{0.27\columnwidth}\centering\strut
Residual Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.11\columnwidth}\centering\strut
\(R^2\)\strut
\end{minipage} & \begin{minipage}[b]{0.20\columnwidth}\centering\strut
Adjusted \(R^2\)\strut
\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.18\columnwidth}\centering\strut
Observations\strut
\end{minipage} & \begin{minipage}[b]{0.27\columnwidth}\centering\strut
Residual Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.11\columnwidth}\centering\strut
\(R^2\)\strut
\end{minipage} & \begin{minipage}[b]{0.20\columnwidth}\centering\strut
Adjusted \(R^2\)\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.18\columnwidth}\centering\strut
93\strut
\end{minipage} & \begin{minipage}[t]{0.27\columnwidth}\centering\strut
61.43\strut
\end{minipage} & \begin{minipage}[t]{0.11\columnwidth}\centering\strut
0.9634\strut
\end{minipage} & \begin{minipage}[t]{0.20\columnwidth}\centering\strut
0.9579\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

The diagnostic plots for our first model are shown in Figure
\ref{f:2a_diagnostic}. Our standard set of diagnostic plots, the first
four plots, don't look too bad although there are some deviations from
normality in the QQ plot and maybe an upward trend in the Scale-Location
plot. We see in the ACF plot that there is, statistically significant,
auto-correlation in the lag1 term for the residuals. We also plot the
residuals against the Time variable, which could conceivably be used to
address the auto correlation but we do not observe any trends in this
plot. We could estimate a model to account for the observed auto
correlation but we will defer that until the next part since it is
hypothesize that advertising in both the current and previous month may
be important variables, and could conceivably account for the auto
correlation. We do note that the current model explains a large portion
of the observed variation and is straight forward to interpret relying
only on the month of the year and the Time (cumulative count of months).

\begin{figure}
\centering
\includegraphics{hw08_solutions_files/figure-latex/2a_diagnostic-1.pdf}
\caption{Problem 2a: Diagnostic plots for ordinary linear
model.\label{f:2a_diagnostic}}
\end{figure}

\section{2 (b)}\label{b}

We try adding the Advert and Lag1Advert

\begin{longtable}[]{@{}ccccc@{}}
\toprule
\begin{minipage}[b]{0.21\columnwidth}\centering\strut
~\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering\strut
Estimate\strut
\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\centering\strut
Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering\strut
t value\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering\strut
Pr(\textgreater{}\textbar{}t\textbar{})\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{(Intercept)}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
392.4\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
40.81\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
9.614\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
6.994e-15\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Advert}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
2.3\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
2.574\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
0.8934\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.3744\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Lag1Advert}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
-4.517\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
2.663\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
-1.697\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.09374\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Time}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.4322\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
0.2377\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
1.818\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.07285\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_2}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
-45.88\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
37.83\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
-1.213\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.2288\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_3}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
26.69\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
40.59\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
0.6576\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.5127\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_4}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
81.05\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
33.55\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
2.416\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.01803\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_5}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
59.33\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
36.74\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
1.615\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.1104\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_6}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
59.36\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
36.42\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
1.63\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.1072\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_7}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
-12.4\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
37.42\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
-0.3314\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.7412\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_8}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
60.02\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
35.91\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
1.671\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.09865\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_9}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
129\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
37.24\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
3.464\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.0008671\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_10}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
165.7\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
35.43\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
4.677\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.000012\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_11}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
324.8\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
43.59\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
7.451\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
1.081e-10\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Month\_12}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
1149\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
39.48\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
29.11\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
1.209e-43\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

\begin{longtable}[]{@{}cccc@{}}
\caption{Problem 2b: Summary of ordinary linear model.}\tabularnewline
\toprule
\begin{minipage}[b]{0.18\columnwidth}\centering\strut
Observations\strut
\end{minipage} & \begin{minipage}[b]{0.27\columnwidth}\centering\strut
Residual Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.11\columnwidth}\centering\strut
\(R^2\)\strut
\end{minipage} & \begin{minipage}[b]{0.20\columnwidth}\centering\strut
Adjusted \(R^2\)\strut
\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.18\columnwidth}\centering\strut
Observations\strut
\end{minipage} & \begin{minipage}[b]{0.27\columnwidth}\centering\strut
Residual Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.11\columnwidth}\centering\strut
\(R^2\)\strut
\end{minipage} & \begin{minipage}[b]{0.20\columnwidth}\centering\strut
Adjusted \(R^2\)\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.18\columnwidth}\centering\strut
93\strut
\end{minipage} & \begin{minipage}[t]{0.27\columnwidth}\centering\strut
60.55\strut
\end{minipage} & \begin{minipage}[t]{0.11\columnwidth}\centering\strut
0.9653\strut
\end{minipage} & \begin{minipage}[t]{0.20\columnwidth}\centering\strut
0.9591\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

We can see from the model outputs that neither Advert or Lag1Advert is
statistically significant. Conducting an ANOVA test (results below) we
see that we fail to reject the null hypothesis that the model without
either Advert or Lag1Advert performs as well as the larger model.
Examining the diagnostic plots for the larger model in Figure
\ref{f:2b_diagnostic} we also the same issues as with the smaller model,
namely: autocorrelation in the residuals and a slight trend in the
scale-location plot. Given the diagnostics we would prefer the model
from part a) but might choose several methods for improving it. We could
try fitting a more general model to allow for the autocorrelation in the
residuals. Alternatively, we could remove or transform the Time variable
yielding a smaller. Since this variable is a just a linear trend it is
possible that this could address the autocorrelation in the residuals
observed in both models.

\begin{figure}
\centering
\includegraphics{hw08_solutions_files/figure-latex/2b_diagnostic-1.pdf}
\caption{Problem 2b: Diagnostic plots for ordinary linear
model.\label{f:2b_diagnostic}}
\end{figure}

\begin{verbatim}
## Analysis of Variance Table
## 
## Model 1: Sales ~ (Advert + Lag1Advert + Time + Month_2 + Month_3 + Month_4 + 
##     Month_5 + Month_6 + Month_7 + Month_8 + Month_9 + Month_10 + 
##     Month_11 + Month_12) - Advert - Lag1Advert
## Model 2: Sales ~ Advert + Lag1Advert + Time + Month_2 + Month_3 + Month_4 + 
##     Month_5 + Month_6 + Month_7 + Month_8 + Month_9 + Month_10 + 
##     Month_11 + Month_12
##   Res.Df    RSS Df Sum of Sq    F Pr(>F)
## 1     80 301843                         
## 2     78 285962  2     15881 2.17   0.12
\end{verbatim}

\section{3 (a)}\label{a-1}

A summary of the model is below. Diagnostic plots are in Figure
\ref{f:3a_diagnostic}, and the estimated autocorrelation between the
residuals is plotted in Figure \ref{f:3a_acf}.

The residuals are very roughly normally distributed, but they appear to
show an increasing trend relative to the fitted values. The
scale-location plot also appears to show that the variance is increasing
with fitted values, and the autocorrelation plot shows large
autocorrelations, all of which suggest that the linear model with
assumed independence between the residuals is not appropriate.

\begin{longtable}[]{@{}ccccc@{}}
\toprule
\begin{minipage}[b]{0.21\columnwidth}\centering\strut
~\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering\strut
Estimate\strut
\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\centering\strut
Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering\strut
t value\strut
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering\strut
Pr(\textgreater{}\textbar{}t\textbar{})\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{(Intercept)}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
4421\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
1235\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
3.58\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
0.00336\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Temp}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
78.18\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
33.89\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
2.307\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
0.03817\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Sun}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
2.585\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
1.556\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
1.661\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
0.1206\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Q2}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
-879.7\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
1121\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
-0.7845\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
0.4468\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Q3}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
-1552\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
1541\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
-1.007\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
0.3323\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.21\columnwidth}\centering\strut
\textbf{Q4}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
715.4\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
474.3\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
1.508\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
0.1554\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

\begin{longtable}[]{@{}cccc@{}}
\caption{Problem 3a: Summary of ordinary linear model.}\tabularnewline
\toprule
\begin{minipage}[b]{0.18\columnwidth}\centering\strut
Observations\strut
\end{minipage} & \begin{minipage}[b]{0.27\columnwidth}\centering\strut
Residual Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.11\columnwidth}\centering\strut
\(R^2\)\strut
\end{minipage} & \begin{minipage}[b]{0.20\columnwidth}\centering\strut
Adjusted \(R^2\)\strut
\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.18\columnwidth}\centering\strut
Observations\strut
\end{minipage} & \begin{minipage}[b]{0.27\columnwidth}\centering\strut
Residual Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.11\columnwidth}\centering\strut
\(R^2\)\strut
\end{minipage} & \begin{minipage}[b]{0.20\columnwidth}\centering\strut
Adjusted \(R^2\)\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.18\columnwidth}\centering\strut
19\strut
\end{minipage} & \begin{minipage}[t]{0.27\columnwidth}\centering\strut
287.2\strut
\end{minipage} & \begin{minipage}[t]{0.11\columnwidth}\centering\strut
0.9537\strut
\end{minipage} & \begin{minipage}[t]{0.20\columnwidth}\centering\strut
0.9359\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

\begin{figure}
\centering
\includegraphics{hw08_solutions_files/figure-latex/3a_diagnostic-1.pdf}
\caption{Problem 3a: Diagnostic plots for ordinary linear
model.\label{f:3a_diagnostic}}
\end{figure}

\begin{figure}

{\centering \includegraphics{hw08_solutions_files/figure-latex/3a_acf-1} 

}

\caption{Problem 3a: acf plot for ordinary linear model residuals.\label{f:3a_acf}}\label{fig:3a_acf}
\end{figure}

\section{3 (b)}\label{b-1}

Note that the model can be estimated with either Maximum Likelihood (ML)
or Restricted Maximum Likelihood (REML). I have used the default, which
is REML, but either one is fine. They will produce different estimates.
The code should look like one of the following:

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{model <-}\StringTok{ }\KeywordTok{gls}\NormalTok{(Sales }\OperatorTok{~}\StringTok{ }\NormalTok{. }\OperatorTok{-}\NormalTok{Case }\OperatorTok{-}\StringTok{ }\NormalTok{Time, }\DataTypeTok{data=}\NormalTok{carlsen, }\DataTypeTok{correlation=}\KeywordTok{corAR1}\NormalTok{())}
\NormalTok{model <-}\StringTok{ }\KeywordTok{gls}\NormalTok{(Sales }\OperatorTok{~}\StringTok{ }\NormalTok{. }\OperatorTok{-}\NormalTok{Case }\OperatorTok{-}\StringTok{ }\NormalTok{Time, }\DataTypeTok{data=}\NormalTok{carlsen, }\DataTypeTok{correlation=}\KeywordTok{corAR1}\NormalTok{(),}
             \DataTypeTok{method =} \StringTok{"ML"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{enumerate}
\def\labelenumi{\roman{enumi}.}
\item
  A summary of this model is below. From this summary, the estimated
  value of \(\rho\), the lag-1 autocorrelation parameter, is 0.87. (If
  you use ML for estimation, the estimate is 0.79).
\item
  The coefficient values have changed in magnitude, though not in sign.
  The estimated standard errors in the AR1 model are much smaller than
  in the ordinary linear model, which is to be expected if the model is
  properly accounting for correlation among the residuals. As a result,
  both \texttt{Sun} and \texttt{Q4} are significant in the AR1 model but
  not in the ordinary linear model at conventional thresholds.
\end{enumerate}

\begin{verbatim}
## Problem 3b: Summary of AR1 model:
\end{verbatim}

\begin{verbatim}
## Generalized least squares fit by REML
##   Model: Sales ~ . - Case - Time 
##   Data: carlsen 
##   AIC BIC logLik
##   213 217    -98
## 
## Correlation Structure: AR(1)
##  Formula: ~1 
##  Parameter estimate(s):
##  Phi 
## 0.87 
## 
## Coefficients:
##             Value Std.Error t-value p-value
## (Intercept)  5215       747     7.0  0.0000
## Temp           56        23     2.4  0.0300
## Sun             2         1     2.8  0.0148
## Q2            -36       663    -0.1  0.9572
## Q3           -371       942    -0.4  0.6999
## Q4            946       295     3.2  0.0069
## 
##  Correlation: 
##      (Intr) Temp   Sun    Q2     Q3    
## Temp -0.870                            
## Sun   0.005 -0.357                     
## Q2    0.914 -0.938  0.033              
## Q3    0.912 -0.960  0.100  0.992       
## Q4    0.747 -0.937  0.485  0.840  0.876
## 
## Standardized residuals:
##   Min    Q1   Med    Q3   Max 
## -1.18 -0.29  0.50  0.57  1.13 
## 
## Residual standard error: 409 
## Degrees of freedom: 19 total; 13 residual
\end{verbatim}

\section{3 (c)}\label{c}

The log likelihoods are -131 for the ordinary linear model and -98 for
the AR1 mode. The difference in degrees of freedom is 1, so we compare
the statistic \(-2(-131-(-98)) = 66\) to a \(\chi_{(1)}^2\)
distribution. The pvalue is \(\ensuremath{8.08\times 10^{-16}}\), so we
reject the null hypothesis and conclude that the autocorrelation is not
0.

\section{3 (d)}\label{d}

A summary of the model is below. Diagnostic plots are in Figure
\ref{f:3d_diagnostic}, and the autocorrelation plot of the residuals is
in Figure \ref{f:3d_acf}.

The diagnostic plots suggest problems with the fit. The residuals are
not very close to normally distributed, and the scale-location plot
appears to show a relationship between the fitted values and the
variance. The autocorrelation plot, however, shows much reduced
autocorrelation among the residuals, as hoped for.

The likelihood of the model is \texttt{-130}, as compared to
\texttt{-98} for the model in 3c. It appears to be more effective to
estimate the autocorrelation simultaneously with estimating the model,
as in 3c, rather than following a two-stage estimation procedure.

\begin{longtable}[]{@{}ccccc@{}}
\toprule
\begin{minipage}[b]{0.27\columnwidth}\centering\strut
~\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering\strut
Estimate\strut
\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\centering\strut
Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering\strut
t value\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering\strut
Pr(\textgreater{}\textbar{}t\textbar{})\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.27\columnwidth}\centering\strut
\textbf{Xstar(Intercept)}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
5090\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
793.5\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
6.415\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.0000229\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.27\columnwidth}\centering\strut
\textbf{XstarTemp}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
61.01\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
24.64\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
2.476\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.02781\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.27\columnwidth}\centering\strut
\textbf{XstarSun}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
2.196\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
0.8827\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
2.488\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.02722\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.27\columnwidth}\centering\strut
\textbf{XstarQ2}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
-214.5\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
725.8\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
-0.2956\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.7722\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.27\columnwidth}\centering\strut
\textbf{XstarQ3}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
-631.1\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
1026\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
-0.6148\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.5493\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.27\columnwidth}\centering\strut
\textbf{XstarQ4}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
879.1\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering\strut
322.7\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering\strut
2.724\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering\strut
0.01738\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

\begin{longtable}[]{@{}cccc@{}}
\caption{Problem 3d: Summary of ordinary linear model with transformed
variables.}\tabularnewline
\toprule
\begin{minipage}[b]{0.18\columnwidth}\centering\strut
Observations\strut
\end{minipage} & \begin{minipage}[b]{0.27\columnwidth}\centering\strut
Residual Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.11\columnwidth}\centering\strut
\(R^2\)\strut
\end{minipage} & \begin{minipage}[b]{0.20\columnwidth}\centering\strut
Adjusted \(R^2\)\strut
\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.18\columnwidth}\centering\strut
Observations\strut
\end{minipage} & \begin{minipage}[b]{0.27\columnwidth}\centering\strut
Residual Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.11\columnwidth}\centering\strut
\(R^2\)\strut
\end{minipage} & \begin{minipage}[b]{0.20\columnwidth}\centering\strut
Adjusted \(R^2\)\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.18\columnwidth}\centering\strut
19\strut
\end{minipage} & \begin{minipage}[t]{0.27\columnwidth}\centering\strut
277.7\strut
\end{minipage} & \begin{minipage}[t]{0.11\columnwidth}\centering\strut
0.9979\strut
\end{minipage} & \begin{minipage}[t]{0.20\columnwidth}\centering\strut
0.9969\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

\begin{figure}
\centering
\includegraphics{hw08_solutions_files/figure-latex/3d_diagnostics-1.pdf}
\caption{Problem 3d: diagnostic plots.\label{f:3d_diagnostic}}
\end{figure}

\begin{figure}
\centering
\includegraphics{hw08_solutions_files/figure-latex/3d_acf-1.pdf}
\caption{Problem 3d: acf plot for ordinary linear model
residuals.\label{f:3d_acf}}
\end{figure}

\newpage

\section{4 (a)}\label{a-2}

We see in Figure \ref{f:4a_plot} that plotting the mean for each state
is helpful in summarizing the overall income level within each stage but
does not give an indication of the relationship between income and high
school graduation rates. Relative to the other plots Figure
\ref{f:4a_plot} is easy to interpret but is probably not the best way to
convey the information it is displaying.

\begin{figure}
\centering
\includegraphics{hw08_solutions_files/figure-latex/4a_plot-1.pdf}
\caption{Problem 4a: HS graduation rate vs.~county level per capita
income with state level mean per capita income line.\label{f:4a_plot}}
\end{figure}

\section{4 (b)}\label{b-2}

Figure \ref{f:4b_plot} allows us to examine if the relationship between
high school graduation rate and income are similar to what is observed
at a national level but it is hard to see what the state level trends
are. Relative to the others plots Figure \ref{f:4b_plot} is best suited
the answering the question of ``Does state X look like nation as a
whole?'' instead of conveying state level results or tends.

\begin{figure}
\centering
\includegraphics{hw08_solutions_files/figure-latex/4b_plot-1.pdf}
\caption{Problem 4b: HS graduation rate vs.~county level per capita
income with national level regression line.\label{f:4b_plot}}
\end{figure}

\section{4 (c)}\label{c-1}

Figure \ref{f:4c_plot} allows us to examine if the relationship between
high school graduation rate and income are similar to what is observed
at a national level while adjusting for mean income in the state but
makes it harder to see how the overall state income level compares to
the nation as a whole. Relative to the others plots Figure
\ref{f:4b_plot} is best suited the answering the question of ``Does the
relationship between high gradation and income in state X look like
nation as a whole?'' but does not convey much about the mean income
level as done in Figure \ref{f:4a_plot} and Figure \ref{f:4b_plot}.

\begin{figure}
\centering
\includegraphics{hw08_solutions_files/figure-latex/4c_plot-1.pdf}
\caption{Problem 4c: HS graduation rate vs.~county level per capita
income with state level intercept and national slope
line.\label{f:4c_plot}}
\end{figure}

\section{4 (d)}\label{d-1}

We see in Figure \ref{f:4d_plot} that the state level regression lines
match the observed data, as closely as possible, but we are unable to
fit them for all states since some states contain only a single county.
In contrast to the other plots there is much greater variance in the
fitted regression lines perhaps better describing each state but Figure
\ref{f:4d_plot} fails to convey any country level trends.

\begin{figure}
\centering
\includegraphics{hw08_solutions_files/figure-latex/4d_plot-1.pdf}
\caption{Problem 4d: HS graduation rate vs.~county level per capita
income with state level regression line.\label{f:4d_plot}}
\end{figure}


\end{document}
