% 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 07 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}{-\maxdimen} % remove section numbering
\usepackage{amsmath}
\usepackage{amsthm}
\DeclareMathOperator{\Cov}{Cov}
\DeclareMathOperator{\Corr}{Corr}

\title{Homework 07 Solutions}
\author{}
\date{\vspace{-2.5em}10/30/2020}

\begin{document}
\maketitle

\hypertarget{sheather-8.3.2}{%
\section{Sheather 8.3.2}\label{sheather-8.3.2}}

First of all, note that the outcome values are not independent, because
exactly 10 jurisdictions produce a top 10 finalist in a given year.
Since the data ranges over 9 years, that means that the sum of the
\texttt{Top10} values must be \(9\times 10 = 90\). That's actually a
pretty strong constraint; it means, for example, that if we observe 10
jurisdictions with the value 9 for \texttt{Top10}, we automatically know
the value for the other 41 jurisdictions (i.e., 0). Of course, we never
expect regression assumptions to hold exactly in practice, but I'd take
this model with a big grain of salt since the samples are so heavily
dependent.

That said, let's go ahead and visualize the data (Figure
\ref{f:pairs1}).

Three predictors, \texttt{LogPopulation}, \texttt{LogContestants}, and
\texttt{Latitude} have high marginal correlations with \texttt{Top10}.
\texttt{LogTotalArea} and \texttt{Longitude} have pretty small
correlations, but of course these are marginal correlations, so they
could still be strongly related to the outcome.

There are some unsurprising correlations between some pairs of
predictors. \texttt{LogPopulation} and \texttt{LogContestants} are
positively correlated, which makes sense: larger populations produce
more contestants. Longitude is positively correlated with
\texttt{LogTotalArea}: western states are larger on average than eastern
ones.

The predictors have reasonably symmetric and unimodal distributions,
presumably thanks in part to the log transformations.

\begin{figure}
\centering
\includegraphics{hw07_solutions_files/figure-latex/scatter-1.pdf}
\caption{Pairs plot for Miss America data, excluding abbreviation
column.\label{f:pairs1}}
\end{figure}

\hypertarget{a-full-model}{%
\subsection{(a): Full model}\label{a-full-model}}

Here's the full model, with a summary below. Standardized deviance
residuals are plotted against each of the predictors in Figure
\ref{f:resid1}. Marginal model plots are in Figure \ref{f:marginal1}.

The residuals look essentially patternless, and the nonparametric curves
for the fitted and the observed values in the marginal model plots look
roughly the same. Since \texttt{Longitude} is not significant, and the
problem requests a model in which all the predictors are significant,
let's drop \texttt{Longitude} and refit (see below).

\begin{longtable}[]{@{}ccccc@{}}
\toprule
\begin{minipage}[b]{0.25\columnwidth}\centering
~\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering
Estimate\strut
\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\centering
Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering
z value\strut
\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\centering
Pr(\textgreater\textbar z\textbar)\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{(Intercept)}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-7.692\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
2.63\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-2.925\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.003446\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogPopulation}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
0.6256\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.1845\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
3.391\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.0006959\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogContestants}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
1.417\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.4213\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
3.364\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.0007675\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogTotalArea}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-0.3701\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.1393\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-2.657\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.007892\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{Latitude}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-0.06525\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.03028\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-2.155\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.03115\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{Longitude}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
0.006509\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.009271\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
0.7021\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.4826\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

(Dispersion parameter for binomial family taken to be 1 )

\begin{longtable}[]{@{}cc@{}}
\toprule
\endhead
\begin{minipage}[t]{0.27\columnwidth}\centering
Null deviance:\strut
\end{minipage} & \begin{minipage}[t]{0.37\columnwidth}\centering
118.47 on 50 degrees of freedom\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.27\columnwidth}\centering
Residual deviance:\strut
\end{minipage} & \begin{minipage}[t]{0.37\columnwidth}\centering
50.11 on 45 degrees of freedom\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

\begin{figure}
\centering
\includegraphics{hw07_solutions_files/figure-latex/residuals1-1.pdf}
\caption{Standardized deviance residuals (left) against fitted values
for the full model.\label{f:resid1}}
\end{figure}

\begin{figure}
\centering
\includegraphics{hw07_solutions_files/figure-latex/marginal1-1.pdf}
\caption{Marginal model plots for the full model\label{f:marginal1}}
\end{figure}

\hypertarget{a-reduced-model-without-longitude}{%
\subsection{\texorpdfstring{(a): Reduced model without
\texttt{Longitude}}{(a): Reduced model without Longitude}}\label{a-reduced-model-without-longitude}}

The model summary is below. Residuals are plotted in Figure
\ref{f:resid1} and the marginal model plots are in Figure
\ref{f:marginal2}.

Once again, the residuals look essentially patternless, and the curves
in each marginal model plot follow each other closely. All the
predictors are now statistically significant. The AIC for this model
(142.79) is also lower than for the full model (144.3). This model seems
reasonable.

\begin{longtable}[]{@{}ccccc@{}}
\toprule
\begin{minipage}[b]{0.25\columnwidth}\centering
~\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering
Estimate\strut
\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\centering
Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering
z value\strut
\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\centering
Pr(\textgreater\textbar z\textbar)\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{(Intercept)}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-6.619\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
2.15\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-3.079\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.002075\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogPopulation}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
0.5888\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.1758\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
3.35\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.0008074\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogContestants}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
1.337\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.4104\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
3.258\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.001123\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogTotalArea}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-0.3198\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.1204\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-2.656\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.007903\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{Latitude}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-0.0733\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.029\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-2.528\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.01148\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

(Dispersion parameter for binomial family taken to be 1 )

\begin{longtable}[]{@{}cc@{}}
\toprule
\endhead
\begin{minipage}[t]{0.27\columnwidth}\centering
Null deviance:\strut
\end{minipage} & \begin{minipage}[t]{0.37\columnwidth}\centering
118.47 on 50 degrees of freedom\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.27\columnwidth}\centering
Residual deviance:\strut
\end{minipage} & \begin{minipage}[t]{0.37\columnwidth}\centering
50.59 on 46 degrees of freedom\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

\begin{figure}
\centering
\includegraphics{hw07_solutions_files/figure-latex/residuals2-1.pdf}
\caption{Standardized deviance residuals (left) against fitted values
for the reduced model.\label{f:resid2}}
\end{figure}

\begin{figure}
\centering
\includegraphics{hw07_solutions_files/figure-latex/marginal2-1.pdf}
\caption{Marginal model plots for the reduced model\label{f:marginal2}}
\end{figure}

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

Recall that a ``bad'' leverage point was defined as a leverage point
that is also an outlier. To detect this, let's examine the diagnostic
plot that R generates with standardized Pearson residuals on the y-axis
and leverage on the x-axis, in Figure \ref{f:leverage}.

Point 12 has both high leverage and a high standardized residual value,
so it could be considered a bad leverage point. Let's refit the model
without that point.

Once again, the residual plots (Figure \ref{f:resid3}) and marginal
model plots (Figure \ref{f:marginal3}) look good. From the summary
below, we see that the coefficient for \texttt{Latitude} is no longer
significant. Point 12 corresponded to Hawaii, which has a very low
latitude, so it makes sense that that point was responsible for making
\texttt{Latitude} statistically significant. The model without Hawaii is
probably a better model of the continental US. (Alaska is still in the
picture, but evidently it's not a bad leverage point, since it didn't
show up as such on the plot.)

\begin{figure}
\centering
\includegraphics{hw07_solutions_files/figure-latex/leverage-1.pdf}
\caption{Residuals vs.~leverage for the reduced model\label{f:leverage}}
\end{figure}

\begin{longtable}[]{@{}ccccc@{}}
\toprule
\begin{minipage}[b]{0.25\columnwidth}\centering
~\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering
Estimate\strut
\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\centering
Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering
z value\strut
\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\centering
Pr(\textgreater\textbar z\textbar)\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{(Intercept)}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-9.741\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
2.938\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-3.315\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.0009168\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogPopulation}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
0.6171\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.1768\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
3.489\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.0004839\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogContestants}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
1.772\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.4994\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
3.549\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.0003872\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogTotalArea}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-0.354\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.1286\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-2.753\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.005905\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{Latitude}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-0.02955\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.03938\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-0.7504\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.453\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

(Dispersion parameter for binomial family taken to be 1 )

\begin{longtable}[]{@{}cc@{}}
\toprule
\endhead
\begin{minipage}[t]{0.27\columnwidth}\centering
Null deviance:\strut
\end{minipage} & \begin{minipage}[t]{0.37\columnwidth}\centering
117.51 on 49 degrees of freedom\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.27\columnwidth}\centering
Residual deviance:\strut
\end{minipage} & \begin{minipage}[t]{0.37\columnwidth}\centering
48.07 on 45 degrees of freedom\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

\begin{figure}
\centering
\includegraphics{hw07_solutions_files/figure-latex/residuals3-1.pdf}
\caption{Standardized deviance residuals (left) against fitted values
for the reduced model without point 12.\label{f:resid3}}
\end{figure}

\begin{figure}
\centering
\includegraphics{hw07_solutions_files/figure-latex/marginal3-1.pdf}
\caption{Marginal model plots for the reduced model without point
12.\label{f:marginal3}}
\end{figure}

As described above, a ``bad'' point is related to high residuals and
high leverage (making it influential). In order to assess this, we need
the residuals to meet our expectations (leverage is only related to the
dependent variables, not the model). In Figure \ref{f:binned2} we can
observe that, only once does a binned grouping have a average residual
beyond the 2 standard deviations, this suggests that the relationship
between residuals and fitted values isn't too concerning. Moreover, we
can't observe any nonconstant pattern with the residual averages.
Additionally, from the marginal plots we know that only 2 observations
have expected values below -4, which might give us pause to
overinterpret the plot. Under the model assumptions, we can simulate
potential outcomes and compare these to the actual values. Figure
\ref{f:sim2} suggests that the residuals observed compared to those from
the simulations do not suggest significant differences, specifically the
ranks for the residuals vs what ranking would be expected seem to have
similar distributions.

\begin{figure}
\centering
\includegraphics{hw07_solutions_files/figure-latex/binned-resid-1.pdf}
\caption{Binned residual plot for second model.\label{f:binned2}}
\end{figure}

\begin{figure}
\centering
\includegraphics{hw07_solutions_files/figure-latex/sim-assessment-1.pdf}
\caption{Simulation based assessment of residuals.\label{f:sim2}}
\end{figure}

\pagebreak

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

Let's interpet the coefficients from the model without Hawaii.

Mathematically, the intercept means that when the covariates are all 0,
the estimated log odds of producing a top 10 finalist is -9.741, which
corresponds to a probability of 0.000059. Of course, a jurisdiction with
0 for all covariate values is not realistic or of interest in the model.

Note that the odds are \begin{align*}
  \frac{\theta(X)}{1 - \theta(X)}
\end{align*} where \(\theta(X)\) represents the probability of producing
a top 10 finalist (given covariates \(X\)) for a single Bernoulli trial.
Since we're pretending that \(Y_i \sim Bin(10, \theta(X_i))\), we have
that \(\theta(X)\) corresponds to the probability of producing a top 10
finalist in a single year. It does not represent the probability of
producing at least one top 10 finalist over 10 ten years or anything
like that.

The coefficient on \texttt{LogPopulation} indicates that, if we observe
two jurisdictions that have the same covariate values except that they
differ by 1 in \texttt{LogPopulation}, then the log odds of producing a
top 10 finalist for the more populous jurisdiction are 0.6171 higher
than for the less populous jurisdiction. Equivalently, the odds are
\texttt{exp(0.671)\ =\ 1.9} higher.

The interpretation is analogous for the other coefficients.

\hypertarget{problem-2}{%
\section{Problem 2}\label{problem-2}}

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

It appears that the ``bernoulli'' dataset is just yearly for each state
if their contestant was in the top 10. This means that the ``binimial''
dataset was a summary of the ``bernoulli'' for each state.

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

Using this Bernoulli data, we show the model without \texttt{Longitude}
below. Because both this model and the second model in part 1a are
trying to to model \(\theta[X_i]\) - the probability in being in the top
10 contestants related to state information and they both use the same
information we expect the model's parameters to be very similar.

\begin{longtable}[]{@{}ccccc@{}}
\toprule
\begin{minipage}[b]{0.25\columnwidth}\centering
~\strut
\end{minipage} & \begin{minipage}[b]{0.13\columnwidth}\centering
Estimate\strut
\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\centering
Std. Error\strut
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering
z value\strut
\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\centering
Pr(\textgreater\textbar z\textbar)\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{(Intercept)}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-6.619\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
2.15\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-3.079\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.002074\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogPopulation}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
0.5888\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.1757\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
3.35\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.0008067\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogContestants}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
1.337\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.4104\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
3.258\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.001123\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{LogTotalArea}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-0.3198\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.1204\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-2.656\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.007899\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.25\columnwidth}\centering
\textbf{Latitude}\strut
\end{minipage} & \begin{minipage}[t]{0.13\columnwidth}\centering
-0.0733\strut
\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\centering
0.029\strut
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering
-2.528\strut
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering
0.01148\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

(Dispersion parameter for binomial family taken to be 1 )

\begin{longtable}[]{@{}cc@{}}
\toprule
\endhead
\begin{minipage}[t]{0.27\columnwidth}\centering
Null deviance:\strut
\end{minipage} & \begin{minipage}[t]{0.37\columnwidth}\centering
454.3 on 458 degrees of freedom\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.27\columnwidth}\centering
Residual deviance:\strut
\end{minipage} & \begin{minipage}[t]{0.37\columnwidth}\centering
386.5 on 454 degrees of freedom\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

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

We should not expect the AICs of the two models to be the same, nor are
they (with the Bernoulli \texttt{m2} model having an AIC of 396.46 and
the binomial \texttt{m2} model having an AIC of 142.79). This directly
related to the definition of AIC, which is

\[-2 \cdot \text{Log likelihood} + 2 \cdot p\;,
\] where \(p\) is the number of parameters of the model (5 in our
models).

The first model has an assumption of the observations being
\(\text{Binomial}(9, \theta[X_i])\) and the second uses the assumption
that the observations are \(\text{Bernoulli}(\theta[X_i])\). The
likelihoods for a state therefore look slightly different, specifically:

\[
\begin{pmatrix}9 \\ x_i \end{pmatrix} \theta[X_i]^{y_i}(1-\theta[X_i])^{9-y_i}
\] for the Binomial assumption and \begin{align*} 
& \prod_{z=2000}^{2009}  \theta[X_i]^{y_{iz}}(1-\theta[X_i])^{1-y_{iz}} \\
\text{or } & \theta[X_i]^{y_{i}}(1-\theta[X_i])^{9-y_{i}}
\;,
\end{align*} for the Bernoulli assumption\footnote{This is because we
  can see \(y_i = \sum_{z=2000}^{2009} y_{iz}\).}. As the log likelihood
is over all \(i\), this means that the Log likelihoods for the model
from part 1 (the Binomial assumption) has an additional

\[
 \sum_{i=1}^{51} \log\left(\begin{pmatrix}9 \\ y_i \end{pmatrix}\right)
 \] term. THe difference between the two AICs should then be by
\(2 * \sum_{i=1}^{51} \log\left(\begin{pmatrix}9 \\ y_i \end{pmatrix}\right)\)
(from the definition of the AIC). The final 2 lines of code below show
that to be true.

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{binomial_m2_aic }\OperatorTok{-}\StringTok{ }\NormalTok{bernoulli_m2_aic  }
\end{Highlighting}
\end{Shaded}

\begin{verbatim}
## [1] -254
\end{verbatim}

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{sapply}\NormalTok{(dat_original}\OperatorTok{$}\NormalTok{Top10, }\ControlFlowTok{function}\NormalTok{(x) }\KeywordTok{choose}\NormalTok{(}\DecValTok{9}\NormalTok{, x)) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{log}\NormalTok{() }\OperatorTok{%>%}\StringTok{ }\KeywordTok{sum}\NormalTok{() }\OperatorTok{%>%}\StringTok{ "*"}\NormalTok{(.,}\OperatorTok{-}\DecValTok{2}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{verbatim}
## [1] -254
\end{verbatim}

\end{document}
