% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
  pdftitle={Homework 02 Solutions},
  hidelinks,
  pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[margin=1in]{geometry}
\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{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\BuiltInTok}[1]{#1}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ControlFlowTok}[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{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ImportTok}[1]{#1}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\usepackage{longtable,booktabs}
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\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}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{5}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage[]{biblatex}
\addbibresource{mybib.bib}

\title{Homework 02 Solutions}
\author{}
\date{\vspace{-2.5em}9/14/2020}

\begin{document}
\maketitle

\hypertarget{sheather-2.8.6}{%
\section{(Sheather 2.8.6)}\label{sheather-2.8.6}}

\hypertarget{a}{%
\subsection{(a)}\label{a}}

\begin{proof}
\begin{align*}
(y_i - \hat{y}_i) &= (y_i - (\hat{\beta}_0 + \hat{\beta}_1 x_i)) && 
                  \text{since } \hat{y}_i = \hat{\beta}_0 + \hat{\beta}_1 x_i \\
                  &= (y_i - (\bar{y} - \hat{\beta}_1\bar{x} + \hat{\beta}_1 x_i)) &&
                  \text{since } \hat{\beta}_0 = \bar{y} - \hat{\beta}_1\bar{x}\\
                  &= (y_i - \bar{y}) - \hat{\beta}_1(x_i - \bar{x})
\end{align*}
\end{proof}

\hypertarget{b}{%
\subsection{(b)}\label{b}}

\begin{proof}
\begin{align*}
(\hat{y}_i - \bar{y}) &= ((\hat{\beta}_0 + \hat{\beta}_1 x_i) - \bar{y}) \\
                  &= ((\bar{y} - \hat{\beta}_1\bar{x} + \hat{\beta}_1 x_i) - \bar{y}) \\
                  &= \hat{\beta}_1(x_i - \bar{x})
\end{align*}
\end{proof}

\hypertarget{c}{%
\subsection{(c)}\label{c}}

\begin{proof}
Substituting the equalities from parts (a) and (b) above, we have:
\begin{align*}
  \sum_{i=1}^n (y_i - \hat{y}_i)(\hat{y}_i - \bar{y}) &= 
  \sum_{i=1}^n [(y_i - \bar{y}) - \hat{\beta}_1(x_i - \bar{x})]\hat{\beta}_1(x_i - \bar{x}) \\
  &= \hat{\beta}_1 \left[\sum_{i=1}^n (y_i-\bar{y})(x_i-\bar{x}) - \hat{\beta}_1 \sum_{i=1}^n (x_i - \bar{x})^2 \right] \\
  &= \hat{\beta}_1 \left[SXY - \frac{SXY}{SXX}SXX\right] \\
  &= \hat{\beta}_1 [SXY - SXY] \\
  &= 0
\end{align*}
\end{proof}

\hypertarget{gelman-hill-2.6}{%
\section{(Gelman \& Hill 2.6)}\label{gelman-hill-2.6}}

\hypertarget{a-1}{%
\subsection{(a)}\label{a-1}}

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{var1 <-}\StringTok{ }\KeywordTok{rnorm}\NormalTok{(}\DecValTok{1000}\NormalTok{, }\DecValTok{0}\NormalTok{, }\DecValTok{1}\NormalTok{)}
\NormalTok{var2 <-}\StringTok{ }\KeywordTok{rnorm}\NormalTok{(}\DecValTok{1000}\NormalTok{, }\DecValTok{0}\NormalTok{, }\DecValTok{1}\NormalTok{)}
\NormalTok{model <-}\StringTok{ }\KeywordTok{lm}\NormalTok{(var2 }\OperatorTok{~}\StringTok{ }\NormalTok{var1)}
\KeywordTok{summary}\NormalTok{(model)}
\end{Highlighting}
\end{Shaded}

\begin{verbatim}
## 
## Call:
## lm(formula = var2 ~ var1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -3.13418 -0.71644 -0.03454  0.72114  2.91643 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  0.01492    0.03250   0.459    0.646  
## var1         0.05713    0.03228   1.770    0.077 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.027 on 998 degrees of freedom
## Multiple R-squared:  0.003129,   Adjusted R-squared:  0.00213 
## F-statistic: 3.133 on 1 and 998 DF,  p-value: 0.07705
\end{verbatim}

The slope is not significantly different from 0, as we can see from the p-value in the \texttt{var1} row, \texttt{Pr(\textgreater{}\textbar{}t\textbar{})} column in the model summary.

\hypertarget{b-1}{%
\subsection{(b)}\label{b-1}}

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{library}\NormalTok{(arm)  }\CommentTok{# Needed for the se.coef() function.}
\NormalTok{z.scores <-}\StringTok{ }\KeywordTok{rep}\NormalTok{(}\OtherTok{NA}\NormalTok{, }\DecValTok{100}\NormalTok{)}
\ControlFlowTok{for}\NormalTok{ (k }\ControlFlowTok{in} \DecValTok{1}\OperatorTok{:}\DecValTok{100}\NormalTok{) \{}
\NormalTok{  var1 <-}\StringTok{ }\KeywordTok{rnorm}\NormalTok{(}\DecValTok{1000}\NormalTok{, }\DecValTok{0}\NormalTok{, }\DecValTok{1}\NormalTok{)}
\NormalTok{  var2 <-}\StringTok{ }\KeywordTok{rnorm}\NormalTok{(}\DecValTok{1000}\NormalTok{, }\DecValTok{0}\NormalTok{, }\DecValTok{1}\NormalTok{)}
\NormalTok{  fit <-}\StringTok{ }\KeywordTok{lm}\NormalTok{(var2 }\OperatorTok{~}\StringTok{ }\NormalTok{var1)}
\NormalTok{  z.scores[k] <-}\StringTok{ }\KeywordTok{coef}\NormalTok{(fit)[}\DecValTok{2}\NormalTok{]}\OperatorTok{/}\KeywordTok{se.coef}\NormalTok{(fit)[}\DecValTok{2}\NormalTok{]}
\NormalTok{\}}

\NormalTok{type1_errors <-}\StringTok{ }\KeywordTok{sum}\NormalTok{(}\KeywordTok{abs}\NormalTok{(z.scores) }\OperatorTok{>}\StringTok{ }\DecValTok{2}\NormalTok{)}
\KeywordTok{print}\NormalTok{(type1_errors)}
\end{Highlighting}
\end{Shaded}

\begin{verbatim}
## [1] 5
\end{verbatim}

There were 5 z-scores that were significant.

\hypertarget{c-1}{%
\subsection{(c)}\label{c-1}}

The rule of thumb to consider a z-score significant if the absolute value exceeds 2 is roughly equivalent to setting \(\alpha = 0.05\), since 95\% of the standard normal
distribution falls within 1.96 standard deviations of the mean of 0. Therefore, we should expect the coefficients to be significant 5 out of 100 times on average, corresponding to a Type 1 error rate of 0.05.

\hypertarget{sheather-2.8.7}{%
\section{(Sheather 2.8.7)}\label{sheather-2.8.7}}

The regression line is defined as \(\mu(x) = E(Y|X = x)\). In other words, it's the
mean value of \(Y\) at a given value of the covariates \(X\). The confidence interval is
for the regression line itself; that is, it's a confidence interval
around an estimated mean. It's entirely possible for the data points themselves to fall outside the 95\% confidence interval for a mean.

To gain some intuition, imagine that you have data from a normal
distribution and you want to estimate the mean of that distribution. The more
data you gather, the narrower the confidence interval around your estimate will
be. The underlying distribution hasn't changed, however, so the more data you
gather, the more of the data will fall outside the confidence interval for the
mean.

\hypertarget{sheather-3.4.8}{%
\section{(Sheather 3.4.8)}\label{sheather-3.4.8}}

\hypertarget{part-1}{%
\subsection{Part 1}\label{part-1}}

\hypertarget{a-2}{%
\subsubsection{(a)}\label{a-2}}

Given the problem constraints, the only flexibility we have is in specifying
the intercept. We could (1) fix the intercept to some value, or (2) estimate the
intercept via least squares.

Option (1) typically means setting the intercept to
0, which can be nice for interpretability in cases where the value (0, 0) is
meaningful and where a different intercept would not make sense. For example,
suppose we were asked to regress the number of words typed in a paper against
the number of hours of work put in. Zero hours of work would necessarily produce zero words, so in that case there is a good reason to set the intercept to 0.

Here, however, the size of a diamond is presumably bounded away from 0. The notion
of a zero-carat diamond doesn't make sense, and no one will manufacture a ring with
a diamond that's so small as to be invisible to the naked eye. Indeed, the sizes of diamonds
in the data range from 0.12 to 0.35 carats. If this is the range we're
interested in modeling, then we may as well give the model the additional
flexibility of a non-zero intercept, since the y-value at the intercept will
not be meaningful regardless.

Hence, we take option (2) and estimate a model of the form
\begin{align*}
  \hat{y}_i = \hat{\beta}_0 + \hat{\beta}_1 x_i
\end{align*}

Although the problem dicatates that we use a linear model, you should always visualize the data before specifying a model to help you decide whether that model is appropriate. Since we only have two variables, let's simply
look at a scatter plot of Price against Size (Figure \ref{fig:5a-scatter}).

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{diamonds <-}\StringTok{ }\KeywordTok{read.table}\NormalTok{(}\StringTok{"../diamonds.txt"}\NormalTok{, }\DataTypeTok{header =} \OtherTok{TRUE}\NormalTok{)}
\KeywordTok{plot}\NormalTok{(Price }\OperatorTok{~}\StringTok{ }\NormalTok{Size, }\DataTypeTok{data =}\NormalTok{ diamonds)}
\end{Highlighting}
\end{Shaded}

\begin{figure}
\centering
\includegraphics{hw02_solutions_files/figure-latex/5a-scatter-1.pdf}
\caption{\label{fig:5a-scatter}Scatter plot of diamond Price against Size}
\end{figure}

It looks like there's a more or less linear relationship, so let's fit the model.

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{model5a <-}\StringTok{ }\KeywordTok{lm}\NormalTok{(Price }\OperatorTok{~}\StringTok{ }\NormalTok{Size, }\DataTypeTok{data =}\NormalTok{ diamonds)}
\end{Highlighting}
\end{Shaded}

The coefficients of the model are

\(\hat{\beta}_0\): -258.05

\(\hat{\beta}_1\): 3715.02

Let's add the best fit line to the scatter plot (Figure \ref{fig:5a-scatter-model}).

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{plot}\NormalTok{(Price }\OperatorTok{~}\StringTok{ }\NormalTok{Size, }\DataTypeTok{data =}\NormalTok{ diamonds)}
\KeywordTok{abline}\NormalTok{(}\DataTypeTok{a =} \KeywordTok{coef}\NormalTok{(model5a)[}\DecValTok{1}\NormalTok{], }\DataTypeTok{b =} \KeywordTok{coef}\NormalTok{(model5a)[}\DecValTok{2}\NormalTok{], }\DataTypeTok{col =} \StringTok{"red"}\NormalTok{, }\DataTypeTok{lty =} \StringTok{"dashed"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{figure}
\centering
\includegraphics{hw02_solutions_files/figure-latex/5a-scatter-model-1.pdf}
\caption{\label{fig:5a-scatter-model}Scatter plot of diamond Price against Size with least squares line}
\end{figure}

The model looks reasonable. We'll examine diagnostic plots in Part 2 below.

\hypertarget{b-2}{%
\subsubsection{(b)}\label{b-2}}

One weakness of the model is that by definition, it cannot capture nonlinearities in the relationship. Additionally, it has only one predictor; additional predictors could
provide additional information. It also cannot deal with nonconstant variance.

\hypertarget{part-2}{%
\subsection{Part 2}\label{part-2}}

\hypertarget{a-3}{%
\subsubsection{(a)}\label{a-3}}

In order to decide whether and how to modify the model above, let's examine some diagnostic plots.
First, the residuals against the predictor (Figure \ref{fig:5a-residuals}).

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{plot}\NormalTok{(model5a}\OperatorTok{$}\NormalTok{residuals }\OperatorTok{~}\StringTok{ }\NormalTok{diamonds}\OperatorTok{$}\NormalTok{Size, }\DataTypeTok{xlab =} \StringTok{"Size"}\NormalTok{, }\DataTypeTok{ylab =} \StringTok{"Residuals"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{figure}
\centering
\includegraphics{hw02_solutions_files/figure-latex/5a-residuals-1.pdf}
\caption{\label{fig:5a-residuals}Model 5a residuals against predictor}
\end{figure}

There's no clear relationship (e.g.~the residuals don't seem to be increasing or decreasing with Size),
so that's good. Now let's examine the diagnostic plots that R produces for us automatically (Figure \ref{fig:5a-diagnostics}).

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{par}\NormalTok{(}\DataTypeTok{mfrow =} \KeywordTok{c}\NormalTok{(}\DecValTok{2}\NormalTok{, }\DecValTok{2}\NormalTok{), }\DataTypeTok{mar =} \KeywordTok{c}\NormalTok{(}\DecValTok{4}\NormalTok{, }\FloatTok{4.5}\NormalTok{, }\FloatTok{2.5}\NormalTok{, }\DecValTok{4}\NormalTok{)) }\CommentTok{# reducing the margins slightly}
\KeywordTok{plot}\NormalTok{(model5a)                                 }\CommentTok{# generating diagnostic plots}
\end{Highlighting}
\end{Shaded}

\begin{figure}
\centering
\includegraphics{hw02_solutions_files/figure-latex/5a-diagnostics-1.pdf}
\caption{\label{fig:5a-diagnostics}Diagnostic plots for model 5a}
\end{figure}

Let's discuss each of these in turn:

\begin{itemize}
\tightlist
\item
  The top left plot shows no relationship between the residuals and the fitted values (the \(\hat{y}_i\)s), so that's good.
\item
  The top right plot shows that the residuals are approximately normally distributed, which is also good.
\item
  The nonparametric red line in the bottom left plot shows a slight increasing trend between the fitted values and the standardized residuals, but there aren't many data points on the right side of the plot, so I wouldn't take this too seriously. (Recall that the variance of the residuals \(\hat{e}_i\) is nonconstant, \emph{even if the variance of the underlying errors $e_i$ is constant}. The standardized residuals have approximately constant variance, so it is useful to examine these instead of the raw residuals, particularly when points of high leverage exist.)
\item
  The bottom right plot shows that there are a couple outliers in the sense defined in Sheather: points whose standardized residual falls outside the range {[}-2, 2{]}. R has helpfully labeled these points with their row numbers in the data, so we can examine them. Additionally, recall the rule of thumb that a point is ``high leverage,'' or equivalently a ``leverage point,'' if its leverage value \(h_{ii}\) is greater than \(4/n\), where \(n\) is the number of data points. In this case, \(4/n = 4/49 \approx 0.082\), so we have a couple of leverage points in the data. One of these, point 42, has a relatively high Cook's distance; it lies close to the contour line that represents a Cook's distance of 0.5.
\end{itemize}

Since R has helpfully labeled points 4, 19, and 42 for us in the bottom right diagnostic plot, let's examine these on the original graph (Figure \ref{fig:5a-leverage-points}).

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{plot}\NormalTok{(Price }\OperatorTok{~}\StringTok{ }\NormalTok{Size, }\DataTypeTok{data =}\NormalTok{ diamonds)}
\KeywordTok{abline}\NormalTok{(}\DataTypeTok{a =} \KeywordTok{coef}\NormalTok{(model5a)[}\DecValTok{1}\NormalTok{], }\DataTypeTok{b =} \KeywordTok{coef}\NormalTok{(model5a)[}\DecValTok{2}\NormalTok{], }\DataTypeTok{col =} \StringTok{"red"}\NormalTok{, }\DataTypeTok{lty =} \StringTok{"dashed"}\NormalTok{)}
\KeywordTok{points}\NormalTok{(diamonds[}\KeywordTok{c}\NormalTok{(}\DecValTok{4}\NormalTok{, }\DecValTok{19}\NormalTok{, }\DecValTok{42}\NormalTok{), ], }\DataTypeTok{col =} \StringTok{"red"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{figure}
\centering
\includegraphics{hw02_solutions_files/figure-latex/5a-leverage-points-1.pdf}
\caption{\label{fig:5a-leverage-points}Scatter plot of diamond Price against Size with least squares line and points 4, 19, 42 highlighted\label{fig:scatter4}}
\end{figure}

None of these points is obviously problematic. Let's check one more diagnostic, the inverse response plot:

\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{# install.packages("alr3")  # if you don't already have it installed}
\KeywordTok{library}\NormalTok{(alr3)}
\KeywordTok{invisible}\NormalTok{(}\KeywordTok{inverseResponsePlot}\NormalTok{(model5a))}
\end{Highlighting}
\end{Shaded}

\begin{figure}
\centering
\includegraphics{hw02_solutions_files/figure-latex/5a-inverse-response-1.pdf}
\caption{\label{fig:5a-inverse-response}Inverse response plot for the diamonds model5a}
\end{figure}

Based on this plot, it looks like the original model, represented by the light blue line (\(\lambda = 1\)) fits the data well. It doesn't look like we would do better transforming the response variable, at least not with a scaled power transformation.

Given these results, it seems reasonable to keep the original model in 5(a)

\hypertarget{b-3}{%
\subsubsection{(b)}\label{b-3}}

Since the model hasn't changed, see 5(a).

\hypertarget{part-3}{%
\subsection{Part 3}\label{part-3}}

The model did not change.

\hypertarget{imrad-and-idmrad-analysis}{%
\section{5. IMRAD and IDMRAD analysis}\label{imrad-and-idmrad-analysis}}

\hypertarget{a-4}{%
\subsection{(a)}\label{a-4}}

\hypertarget{abstract}{%
\subsubsection{Abstract}\label{abstract}}

\textbf{Yes,} \emph{this section has the right content.} The section nicely summarizes the later sections (introduction, method, results and discussion) and provides a clear overview.

\hypertarget{introduction}{%
\subsubsection{Introduction}\label{introduction}}

\textbf{Yes,} \emph{this section has the right content.} This section does well at motivating why we might be interested in examining the relationship between a critic's rating and the wine's price. It also clearly highlights the 3 questions that the paper will attempt to answer.

This introduction could be improved by more clearly highlighting the connection between the second and third questions to the first question (which is directly related to the motivation in the first paragraph)\footnote{This comment could suggest that our answer should be actually ``No, the introduction section does not contain the expected content''.}.

\hypertarget{methods}{%
\subsubsection{Methods}\label{methods}}

\textbf{No,} \emph{this section's content does not meet expectations.} This section doesn't highlight (in writing) a lot of the methods that were used to to answer the questions posed. Specifically, all 3 analytics tools are is only mentioned in passing in the final sentence of the section. No motivation is provided to suggest why such analysis was done, which should have at least occured for Figure 2's log-transformation of the price and scores.

In terms of the organization advice given on slide 9 of lecture 02 (week01), the method section failed to use a ``context, content, and conclusion'' structure in presenting what methods were used. This is especially true for this section as the figures are presented first without any discussion of what was done.

As most of this section presents data information, it might be useful for the author to switch to an IDMRAD approach and put that information into a Data section. In the commentary on the \textbf{results} section of the paper in section \ref{results}, I will discuss parts of results that really should be in the methods section in more details.

\hypertarget{results}{%
\subsubsection{Results}\label{results}}

\textbf{No,} \emph{this section's content does not meet expectations.} As alluded to above, the results section contains several pieces that really should be in the \textbf{methods} section. Specifically, the descriptions of the methods / figures used should be in the method section. Additionally, the discussion of the motivation of using a log transformation should have introduced Figure 2 in the methods section.

Additionally, this section presents the idea that the slope of regression line (relating the critic's scores to the price point) is a valuable measure to compare the critic's impact even though the scales are different. This is hard to justify and muddies the water in terms of making sure the reader agrees with the conclusions (\#7 of slide 9). Another, slightly nit-picky critique of this section, would be that the introduction failed to well motivate the later 2 questions and the author spent a lot of time discussion the results related to the questions without well motivating the results. This might lose a reader and relates to \#9 of slide 9 - allocation the time of the reader wisely.

This section's commentary on the spread of the prices relative to the critic's score does attempt to well address the question relative to the methods used, and if I was an editor / advisor I would encourage that to be expanded on.

\hypertarget{discussion}{%
\subsection{Discussion}\label{discussion}}

\textbf{Yes,} \emph{this section has the right content.} Conditional on the comments above, the \textbf{discussion} section does highlight overarching conclusions, and this section spends a lot of time discussion limitations and future improvements. The author did convert potential criticisms of the work into limitations and future work ideas.

If anything, this section spends the vast majority of presenting limitations and could have been better structured to capture that idea.

\pagebreak

\hypertarget{b-4}{%
\subsection{(b)}\label{b-4}}

\emph{A rewrite of the \textbf{Data} and \textbf{Methods} section. Stylistically, I tried to stay as close to the current write-up as possible.}

\textbf{Data}

The data for this study come from \textcite{parker2003} and \textcite{coates2004}. The prices (in pounds sterling) include duty but exclude shipping and VAT in London in September 2003 \autocite[pp.~8]{sheather2009}. Parker's rating system is 100-point based and the scale can be seen in Figure \ref{fig:tab-parker}. Whereas Coates' rating system is 20-point based and can be seen in Figure \ref{fig:tab-coates}. The dataset contains prices for 72 wines from the 2000 vintage in Bordeaux, and all the variables in Figure \ref{fig:tab-variables}, and was obtained from supplementary material provided by \textcite{sheather2009}.

\begin{figure}[h]

{\centering \includegraphics[width=0.5\linewidth]{../Table01} 

}

\caption{Parker's rating system for wine}\label{fig:tab-parker}
\end{figure}

\begin{figure}[h]

{\centering \includegraphics[width=0.5\linewidth]{../Table02} 

}

\caption{Coates' rating system for wine}\label{fig:tab-coates}
\end{figure}

\begin{figure}[h]

{\centering \includegraphics[width=0.8\linewidth]{../Table03} 

}

\caption{Description of dataset's variables}\label{fig:tab-variables}
\end{figure}

\textbf{Methods}

In order to understand the relationship between the prices of wine and critics scores we creates a set of scatter plots relating these two variables together. Figure \ref{fig:fig-matrixplot1} shows these relationships and the relationship between Parker and Coates' critic scores of the same wines. From \ref{fig:fig-matrixplot1}'s plots relating both critic's scores to the price of wine, we saw that the data points demonstrate an exponential trend, as such, we created a log-log transformation of plots in Figure \ref{fig:fig-matrixplot1} as can be seen in Figure \ref{fig:fig-matrixplot2}.

\begin{figure}[h]

{\centering \includegraphics[width=0.5\linewidth]{../Fig01} 

}

\caption{Pairwise scatterplots of critic scores and prices of wines.}\label{fig:fig-matrixplot1}
\end{figure}

\begin{figure}[h]

{\centering \includegraphics[width=0.5\linewidth]{../Fig02} 

}

\caption{Pairwise scatterplots of critic scores and prices of wines (log-log transformed).}\label{fig:fig-matrixplot2}
\end{figure}

Beyond critic's scores, we explored the relationship between the price of wine and some binary variables that might also effect the wine's price in Figure \ref{fig:fig-boxplot} by comparing the distribution of prices conditional on these binary variables values.

\begin{figure}[h]

{\centering \includegraphics[width=0.8\linewidth]{../Fig03} 

}

\caption{Boxplots comparing the price of wine conditional on additional features about the wine (see Figure \ref{fig:tab-variables} for more details).}\label{fig:fig-boxplot}
\end{figure}

\printbibliography

\end{document}
