% 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 11 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{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}
\DeclareMathOperator{\Var}{Var}
\DeclareMathOperator{\upmodels}{\perp \!\!\! \perp}

\title{Homework 11 Solutions}
\author{}
\date{\vspace{-2.5em}11/28/2020}

\begin{document}
\maketitle

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

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{library}\NormalTok{(tidyverse)}
\KeywordTok{library}\NormalTok{(arm)}
\KeywordTok{library}\NormalTok{(lme4)}
\KeywordTok{library}\NormalTok{(latex2exp) }\CommentTok{# for nice plot labeling (using latex notation)}

\NormalTok{cdi <-}\StringTok{ }\KeywordTok{read.table}\NormalTok{(}\DataTypeTok{file =} \StringTok{"../cdi.dat"}\NormalTok{)}

\NormalTok{cdi}\OperatorTok{$}\NormalTok{pci <-}\StringTok{ }\KeywordTok{rescale}\NormalTok{(}\DecValTok{2}\OperatorTok{*}\NormalTok{cdi}\OperatorTok{$}\NormalTok{per.cap.income) }
\NormalTok{cdi}\OperatorTok{$}\NormalTok{phg <-}\StringTok{ }\KeywordTok{rescale}\NormalTok{(}\DecValTok{2}\OperatorTok{*}\NormalTok{cdi}\OperatorTok{$}\NormalTok{pct.hs.grad)}
\end{Highlighting}
\end{Shaded}

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

See Figure \ref{f:fig1a}.

\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{# pooled regression}
\NormalTok{lm_all <-}\StringTok{ }\KeywordTok{lm}\NormalTok{(pci }\OperatorTok{~}\StringTok{ }\NormalTok{phg, }\DataTypeTok{data =}\NormalTok{ cdi)}

\NormalTok{lm_all_rep <-}\StringTok{ }\KeywordTok{data.frame}\NormalTok{(}\DataTypeTok{intercept =}\NormalTok{ lm_all[[}\StringTok{"coefficients"}\NormalTok{]][}\DecValTok{1}\NormalTok{],}
                         \DataTypeTok{slope =}\NormalTok{ lm_all[[}\StringTok{"coefficients"}\NormalTok{]][}\DecValTok{2}\NormalTok{],}
                         \DataTypeTok{state =} \KeywordTok{unique}\NormalTok{(cdi}\OperatorTok{$}\NormalTok{state))}

\CommentTok{# unpooled regression}
\NormalTok{state_lm_func <-}\StringTok{ }\ControlFlowTok{function}\NormalTok{(df)\{}
\NormalTok{    mod <-}\StringTok{ }\KeywordTok{lm}\NormalTok{(pci }\OperatorTok{~}\StringTok{ }\NormalTok{phg, }\DataTypeTok{data =}\NormalTok{ df)}
    \KeywordTok{return}\NormalTok{(}\KeywordTok{data.frame}\NormalTok{(}\DataTypeTok{intercept =}\NormalTok{ mod[[}\StringTok{"coefficients"}\NormalTok{]][}\DecValTok{1}\NormalTok{], }
                      \DataTypeTok{slope =}\NormalTok{ mod[[}\StringTok{"coefficients"}\NormalTok{]][}\DecValTok{2}\NormalTok{]))}
\NormalTok{\}}

\NormalTok{state_lm_df <-}\StringTok{ }\NormalTok{cdi }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{group_by}\NormalTok{(state) }\OperatorTok{%>%}\StringTok{ }\KeywordTok{do}\NormalTok{(., }\KeywordTok{state_lm_func}\NormalTok{(.))}

\CommentTok{## unpooled regression version II}
\NormalTok{lm_unpooled <-}\StringTok{ }\KeywordTok{lm}\NormalTok{(pci }\OperatorTok{~}\StringTok{ }\NormalTok{state }\OperatorTok{+}\StringTok{ }\NormalTok{phg}\OperatorTok{:}\NormalTok{state }\OperatorTok{-}\StringTok{ }\DecValTok{1}\NormalTok{, }\DataTypeTok{data =}\NormalTok{ cdi) }\CommentTok{# single model}

\NormalTok{coef_unpooled <-}\StringTok{ }\KeywordTok{coef}\NormalTok{(lm_unpooled)}
\NormalTok{state_loc <-}\StringTok{ }\KeywordTok{substring}\NormalTok{(}\KeywordTok{names}\NormalTok{(coef_unpooled), }\DecValTok{6}\NormalTok{,}\DecValTok{7}\NormalTok{)}
\NormalTok{slope_loc <-}\StringTok{ }\KeywordTok{substring}\NormalTok{(}\KeywordTok{names}\NormalTok{(coef_unpooled), }\DecValTok{9}\NormalTok{,}\DecValTok{11}\NormalTok{)}

\NormalTok{intercepts <-}\StringTok{ }\NormalTok{coef_unpooled[slope_loc }\OperatorTok{==}\StringTok{ ""}\NormalTok{] }
\NormalTok{intercepts_df <-}\StringTok{ }\KeywordTok{data.frame}\NormalTok{(}\DataTypeTok{state =} \KeywordTok{substring}\NormalTok{(}\KeywordTok{names}\NormalTok{(intercepts), }\DecValTok{6}\NormalTok{,}\DecValTok{7}\NormalTok{),}
                            \DataTypeTok{intercept =}\NormalTok{ intercepts)}
\NormalTok{slopes <-}\StringTok{ }\NormalTok{coef_unpooled[slope_loc }\OperatorTok{==}\StringTok{ "phg"}\NormalTok{]}
\NormalTok{slopes_df <-}\StringTok{ }\KeywordTok{data.frame}\NormalTok{(}\DataTypeTok{state =} \KeywordTok{substring}\NormalTok{(}\KeywordTok{names}\NormalTok{(slopes), }\DecValTok{6}\NormalTok{,}\DecValTok{7}\NormalTok{),}
                        \DataTypeTok{slope =}\NormalTok{ slopes)}

\NormalTok{state_lm_df2 <-}\StringTok{ }\NormalTok{intercepts_df }\OperatorTok{%>%}\StringTok{ }\KeywordTok{left_join}\NormalTok{(slopes_df, }\DataTypeTok{by =} \StringTok{'state'}\NormalTok{)}

\NormalTok{testthat}\OperatorTok{::}\KeywordTok{expect_equivalent}\NormalTok{(state_lm_df, state_lm_df2) }\CommentTok{# no error - so true}

\CommentTok{## unpooled regression version III}
\NormalTok{lm_unpooled2 <-}\StringTok{ }\KeywordTok{lm}\NormalTok{(pci }\OperatorTok{~}\StringTok{ }\NormalTok{state}\OperatorTok{*}\NormalTok{phg }\OperatorTok{-}\StringTok{ }\DecValTok{1} \OperatorTok{-}\StringTok{ }\NormalTok{phg, }\DataTypeTok{data =}\NormalTok{ cdi) }\CommentTok{# single model}

\NormalTok{coef_unpooled2 <-}\StringTok{ }\KeywordTok{coef}\NormalTok{(lm_unpooled2)}
\NormalTok{state_loc2 <-}\StringTok{ }\KeywordTok{substring}\NormalTok{(}\KeywordTok{names}\NormalTok{(coef_unpooled2), }\DecValTok{6}\NormalTok{,}\DecValTok{7}\NormalTok{)}
\NormalTok{slope_loc2 <-}\StringTok{ }\KeywordTok{substring}\NormalTok{(}\KeywordTok{names}\NormalTok{(coef_unpooled2), }\DecValTok{9}\NormalTok{,}\DecValTok{11}\NormalTok{)}

\NormalTok{intercepts2 <-}\StringTok{ }\NormalTok{coef_unpooled2[slope_loc2 }\OperatorTok{==}\StringTok{ ""}\NormalTok{] }
\NormalTok{intercepts_df2 <-}\StringTok{ }\KeywordTok{data.frame}\NormalTok{(}\DataTypeTok{state =} \KeywordTok{substring}\NormalTok{(}\KeywordTok{names}\NormalTok{(intercepts2), }\DecValTok{6}\NormalTok{,}\DecValTok{7}\NormalTok{),}
                             \DataTypeTok{intercept =}\NormalTok{ intercepts2)}
\NormalTok{slopes2 <-}\StringTok{ }\NormalTok{coef_unpooled2[slope_loc2 }\OperatorTok{==}\StringTok{ "phg"}\NormalTok{]}
\NormalTok{slopes_df2 <-}\StringTok{ }\KeywordTok{data.frame}\NormalTok{(}\DataTypeTok{state =} \KeywordTok{substring}\NormalTok{(}\KeywordTok{names}\NormalTok{(slopes2), }\DecValTok{6}\NormalTok{,}\DecValTok{7}\NormalTok{),}
                         \DataTypeTok{slope =}\NormalTok{ slopes2)}

\NormalTok{state_lm_df3 <-}\StringTok{ }\NormalTok{intercepts_df2 }\OperatorTok{%>%}\StringTok{ }\KeywordTok{left_join}\NormalTok{(slopes_df2, }\DataTypeTok{by =} \StringTok{'state'}\NormalTok{)}

\NormalTok{testthat}\OperatorTok{::}\KeywordTok{expect_equivalent}\NormalTok{(state_lm_df, state_lm_df3) }\CommentTok{# no error - so true}


\CommentTok{# multilevel model}
\NormalTok{multilevel_lmer <-}\StringTok{ }\KeywordTok{lmer}\NormalTok{(}\DataTypeTok{formula =}\NormalTok{ pci }\OperatorTok{~}\StringTok{ }\DecValTok{1} \OperatorTok{+}\StringTok{ }\NormalTok{phg }\OperatorTok{+}\StringTok{ }\NormalTok{(}\DecValTok{1} \OperatorTok{|}\StringTok{ }\NormalTok{state) }\OperatorTok{+}\StringTok{ }\NormalTok{(}\DecValTok{0} \OperatorTok{+}\StringTok{ }\NormalTok{phg }\OperatorTok{|}\StringTok{ }\NormalTok{state), }
                        \DataTypeTok{data =}\NormalTok{ cdi)}

\NormalTok{multilevel_lmer_df <-}\StringTok{ }\KeywordTok{coef}\NormalTok{(multilevel_lmer)}\OperatorTok{$}\NormalTok{state }\OperatorTok{%>%}
\StringTok{  }\NormalTok{tibble}\OperatorTok{::}\KeywordTok{rownames_to_column}\NormalTok{() }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{rename}\NormalTok{(}\DataTypeTok{state =} \StringTok{"rowname"}\NormalTok{,}
         \DataTypeTok{intercept =} \StringTok{"(Intercept)"}\NormalTok{,}
         \DataTypeTok{slope =} \StringTok{"phg"}\NormalTok{)}

\CommentTok{# multilevel model version II}
\NormalTok{betas <-}\StringTok{ }\KeywordTok{fixef}\NormalTok{(multilevel_lmer)}
\NormalTok{etas <-}\StringTok{ }\KeywordTok{ranef}\NormalTok{(multilevel_lmer)}\OperatorTok{$}\NormalTok{state}

\NormalTok{combo_multilevel_lmer_df <-}\StringTok{ }\NormalTok{etas }\OperatorTok{+}\StringTok{ }
\StringTok{  }\KeywordTok{matrix}\NormalTok{(}\KeywordTok{rep}\NormalTok{(betas, }\DataTypeTok{each =} \KeywordTok{nrow}\NormalTok{(etas)), }\DataTypeTok{nrow =} \KeywordTok{nrow}\NormalTok{(etas))}

\NormalTok{testthat}\OperatorTok{::}\KeywordTok{expect_equivalent}\NormalTok{(combo_multilevel_lmer_df,}
                            \KeywordTok{coef}\NormalTok{(multilevel_lmer)}\OperatorTok{$}\NormalTok{state) }\CommentTok{# doesn't error if true}

\CommentTok{# combined}
\NormalTok{combined <-}\StringTok{ }\KeywordTok{rbind}\NormalTok{(}\KeywordTok{mutate}\NormalTok{(lm_all_rep[, }\KeywordTok{c}\NormalTok{(}\StringTok{"state"}\NormalTok{, }\StringTok{"intercept"}\NormalTok{, }\StringTok{"slope"}\NormalTok{)], }
                         \DataTypeTok{id =} \StringTok{"pooled regression"}\NormalTok{),}
                  \KeywordTok{mutate}\NormalTok{(state_lm_df[, }\KeywordTok{c}\NormalTok{(}\StringTok{"state"}\NormalTok{, }\StringTok{"intercept"}\NormalTok{, }\StringTok{"slope"}\NormalTok{)], }
                         \DataTypeTok{id =} \StringTok{"unpooled regression"}\NormalTok{),}
                  \KeywordTok{mutate}\NormalTok{(multilevel_lmer_df[, }\KeywordTok{c}\NormalTok{(}\StringTok{"state"}\NormalTok{, }\StringTok{"intercept"}\NormalTok{, }\StringTok{"slope"}\NormalTok{)],}
                         \DataTypeTok{id =} \StringTok{"multilevel model"}\NormalTok{)) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{mutate}\NormalTok{(}\DataTypeTok{id =} \KeywordTok{factor}\NormalTok{(id, }\DataTypeTok{levels =} \KeywordTok{c}\NormalTok{(}\StringTok{"pooled regression"}\NormalTok{,}
                                    \StringTok{"unpooled regression"}\NormalTok{,}
                                    \StringTok{"multilevel model"}\NormalTok{)))}
\end{Highlighting}
\end{Shaded}

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{ggplot}\NormalTok{(cdi) }\OperatorTok{+}
\StringTok{  }\KeywordTok{geom_point}\NormalTok{(}\KeywordTok{aes}\NormalTok{(}\DataTypeTok{x =}\NormalTok{ phg, }\DataTypeTok{y=}\NormalTok{ pci)) }\OperatorTok{+}
\StringTok{  }\KeywordTok{geom_abline}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ combined,}
              \KeywordTok{aes}\NormalTok{(}\DataTypeTok{slope =}\NormalTok{ slope, }\DataTypeTok{intercept=}\NormalTok{ intercept, }\DataTypeTok{group =}\NormalTok{ state,}
                  \DataTypeTok{color =}\NormalTok{ id))}\OperatorTok{+}
\StringTok{  }\KeywordTok{facet_wrap}\NormalTok{(}\OperatorTok{~}\StringTok{ }\NormalTok{state) }\OperatorTok{+}
\StringTok{  }\KeywordTok{theme_minimal}\NormalTok{() }\OperatorTok{+}
\StringTok{  }\KeywordTok{labs}\NormalTok{(}\DataTypeTok{color =} \StringTok{"model type"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{figure}
\centering
\includegraphics{hw11_solutions_files/figure-latex/unnamed-chunk-3-1.pdf}
\caption{Problem 1a: Different linear models to compare per capital
income to percent high school graduates \label{f:fig1a}.}
\end{figure}

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

See figure \ref{f:fig1b}.

\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{# multilevel model}
\NormalTok{multilevel_res_fit <-}\StringTok{ }\KeywordTok{data.frame}\NormalTok{(}\DataTypeTok{fitted =} \KeywordTok{fitted}\NormalTok{(multilevel_lmer), }
                                 \DataTypeTok{residual =} \KeywordTok{resid}\NormalTok{(multilevel_lmer), }
                                 \DataTypeTok{state =}\NormalTok{ cdi}\OperatorTok{$}\NormalTok{state)}

\CommentTok{# multilevel model, part II}
\KeywordTok{source}\NormalTok{(}\StringTok{"../residual-functions.r"}\NormalTok{)}
\NormalTok{multilevel_res_fit2 <-}\StringTok{ }\KeywordTok{data.frame}\NormalTok{(}\DataTypeTok{fitted =} \KeywordTok{yhat.cond}\NormalTok{(multilevel_lmer),}
                                  \DataTypeTok{residual =} \KeywordTok{r.cond}\NormalTok{(multilevel_lmer),}
                                  \DataTypeTok{state =}\NormalTok{ cdi}\OperatorTok{$}\NormalTok{state)}

\NormalTok{testthat}\OperatorTok{::}\KeywordTok{expect_equivalent}\NormalTok{(multilevel_res_fit, multilevel_res_fit2) }\CommentTok{# no error if true}
\end{Highlighting}
\end{Shaded}

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{multilevel_res_fit }\OperatorTok{%>%}
\KeywordTok{ggplot}\NormalTok{() }\OperatorTok{+}
\StringTok{  }\KeywordTok{geom_point}\NormalTok{(}\KeywordTok{aes}\NormalTok{(}\DataTypeTok{x =}\NormalTok{ fitted, }\DataTypeTok{y =}\NormalTok{ residual)) }\OperatorTok{+}
\StringTok{  }\KeywordTok{facet_wrap}\NormalTok{(}\OperatorTok{~}\StringTok{ }\NormalTok{state) }\OperatorTok{+}
\StringTok{  }\KeywordTok{geom_hline}\NormalTok{(}\DataTypeTok{yintercept =} \DecValTok{0}\NormalTok{) }\OperatorTok{+}
\StringTok{  }\KeywordTok{theme_minimal}\NormalTok{() }\OperatorTok{+}
\StringTok{  }\KeywordTok{labs}\NormalTok{(}\DataTypeTok{y =} \StringTok{"conditional residual"}\NormalTok{,}
       \DataTypeTok{x =} \KeywordTok{TeX}\NormalTok{(}\StringTok{"conditional $}\CharTok{\textbackslash{}\textbackslash{}}\StringTok{hat\{y\}$"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}

\begin{figure}
\centering
\includegraphics{hw11_solutions_files/figure-latex/unnamed-chunk-5-1.pdf}
\caption{Problem 1b: Examinig the conditional residual vs conditional
\(\hat{y}\) for multilevel model \label{f:fig1b}.}
\end{figure}

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

Intentionally missing.

\end{document}
