
```{r setup, include=FALSE, cache=FALSE}
# # require(xtable)
# require(fastR)
# require(mosaic)
# require(tidyverse)
# require(gap)
# require(ggformula)
# require(alr3)
library(knitr)
library(rgl)
options(format.R.blank=FALSE) 
options(width=80)
options(continue=" ")
options(replace.assign=TRUE)
options(scipen=8, digits=4)
knitr::opts_chunk$set(
  size = 'small', 
  par=TRUE, 
  tidy=FALSE,
  prompt=FALSE,
  comment=NA,
  echo=TRUE,
  collapse=TRUE
)
knitr::opts_chunk$set(cache=TRUE)
# Tighten the spacing within R output from knitr
hook1 <- function(x){ gsub("```\n*```r*\n*", "", x) }
hook2 <- function(x){ gsub("```\n+```\n", "", x) }
knitr::knit_hooks$set(
  webgl = hook_webgl,
  rgl.static = hook_rgl, # use to capture a single rgl graphic
  crop=knitr::hook_pdfcrop,
    inline = function(x) {
      if(is.numeric(x)){
          return(prettyNum(x, big.mark=","))
      }else{
          return(x)
       }
   },
  document = hook1,
  par=function(before, options, envir){
    if (before) {
    ## load packages before a chunk is executed
    for (p in options$packages) library(p, character.only = TRUE)
    }
  } 
)
knitr::opts_knit$set(concordance=TRUE, self.contained=FALSE)
# For printing code blocks in black and white
# knitr::knit_theme$set("greyscale0") 


uchicago.lattice.theme=mosaic::col.mosaic(bw=TRUE)
uchicago.lattice.theme$box.dot$pch=20
uchicago.lattice.theme$dot.symbol$pch=20
uchicago.lattice.theme$plot.symbol$pch=20

uchicago.lattice.theme$box.dot$cex=1.0
uchicago.lattice.theme$dot.symbol$cex=1.0
uchicago.lattice.theme$plot.symbol$cex=1.0
uchicago.lattice.theme$layout.heights$main=0.5
uchicago.lattice.theme$layout.heights$top.padding=0.0
uchicago.lattice.theme$layout.heights$bottom.padding=0.0
uchicago.lattice.theme$layout.widths$left.padding=0.75
uchicago.lattice.theme$layout.widths$right.padding=0.75

lattice::trellis.par.set(theme=uchicago.lattice.theme, warn=FALSE)
lattice::trellis.par.set(fontsize=list(text=11,points=5))
```


```{css "css setup", echo=FALSE}
.header-section-number {
  display: none;
}

body {
#  counter-reset: counter-level-1;
#  counter-reset: counter-level-2;
#  counter-reset: kcounter-level-3; 
#  counter-reset: counter-level-4;
}

h1:not(.title) {
  counter-increment: counter-level-1;
  counter-reset: counter-level-2;
  counter-reset: counter-level-4;
    counter-reset: counter-level-3;

}

h1:not(.title)::before{
#  content: counter(counter-level-1, upper-alpha) ". ";
}

h2 {
 counter-increment: counter-level-2;
  counter-reset: counter-level-3;
}

h2::before {
  counter-increment: counter-level-2;
#  content:  counter(counter-level-2) " ";
}

h3 {
  counter-increment: counter-level-3;
  counter-reset: counter-level-4
}

h3::before {
  content:counter(counter-level-3)" ";
}

h4 {
  counter-increment: counter-level-4;
}

h4::before {
  content:counter(counter-level-3) "." counter(counter-level-4) " ";
}

```

```{r load-packages, message=FALSE,cache=TRUE,echo=FALSE}
library(MASS)
library(modelr)
library(car)
library(GGally)
library(gridExtra)
library(tidyverse)
library(mosaic)
library(knitr)
library(ggformula)
library(broom)
```


\newcommand{\xbar}{\overline{x}}
\newcommand{\Xbar}{\overline{X}}
\newcommand{\ybar}{\overline{y}}
\newcommand{\Ybar}{\overline{Y}}
\newcommand{\zbar}{\overline{z}}
\newcommand{\Zbar}{\overline{Z}}
\newcommand{\wbar}{\overline{w}}
\newcommand{\Wbar}{\overline{W}}
\newcommand{\vbar}{\overline{v}}
\newcommand{\Vbar}{\overline{V}}
\newcommand{\dbar}{\overline{d}}
\newcommand{\Dbar}{\overline{D}}
\newcommand{\ebar}{\overline{e}}
\newcommand{\ehat}{\widehat{\epsilon}}
\newcommand{\yhat}{\widehat{y}}
\newcommand{\Yhat}{\widehat{Y}}
\newcommand{\bhat}{\widehat{b}}
\newcommand{\B0}{{\beta_0}}
\newcommand{\B1}{{\beta_1}}
\newcommand{\B2}{{\beta_2}}
\newcommand{\B3}{{\beta_3}}
\newcommand{\Bp}{{\beta_p}}
\newcommand{\BETA}{{\boldsymbol\beta}}
\newcommand{\a0}{\widehat{\alpha}_0}
\newcommand{\a1}{\widehat{\alpha}_1}
\newcommand{\a2}{\widehat{\alpha}_2}
\newcommand{\b0}{\widehat{\beta}_0}
\newcommand{\b1}{\widehat{\beta}_1}
\newcommand{\b2}{\widehat{\beta}_2}
\newcommand{\b3}{\widehat{\beta}_3}
\newcommand{\bp}{\widehat{\beta}_p}
\newcommand{\bj}{\widehat{\beta}_j}
\newcommand{\d0}{\widehat{\delta}_0}
\newcommand{\d1}{\widehat{\delta}_1}
\newcommand{\d2}{\widehat{\delta}_2}
\newcommand{\g0}{\widehat{\gamma}_0}
\newcommand{\g1}{\widehat{\gamma}_1}
\newcommand{\g2}{\widehat{\gamma}_2}
\newcommand{\df}{\mathrm{df}}
\newcommand{\VIF}{\mathrm{VIF}}
\newcommand{\SSE}{\mathrm{SSE}}
\newcommand{\SST}{\mathrm{SST}}
\newcommand{\SSR}{\mathrm{SSR}}
\newcommand{\MSE}{\mathrm{MSE}}
\newcommand{\MST}{\mathrm{MST}}
\newcommand{\MSR}{\mathrm{MSR}}
\newcommand{\RM}{\mathrm{RM}}
\newcommand{\FM}{\mathrm{FM}}
\newcommand{\E}{\mathrm{E}}
\newcommand{\P}{\mathrm{P}}
\newcommand{\var}{\mathrm{var}}
\newcommand{\sd}{\mathrm{sd}}
\newcommand{\se}{\mathrm{se}}
\newcommand{\cov}{\mathrm{cov}}
\newcommand{\corr}{\mathrm{corr}}
\newcommand{\hsigma}{\widehat{\sigma}}
\newcommand{\betahat}{\widehat{\beta}}
\newcommand{\slide}{<br><br><br><br><br>}
\newcommand{\bbeta}{\boldsymbol{\beta}}
\newcommand{\bX}{\mathbf{X}}
\newcommand{\bY}{\mathbf{Y}}
\newcommand{\bH}{\mathbf{H}}
\newcommand{\bI}{\mathbf{I}}
\newcommand{\be}{\mathbf{e}}
\newcommand{\pval}{\mathit{P}\mathrm{-val}}
\newcommand{\pr}{\mathrm{P}}
\newcommand{\logit}{\mathrm{logit}}

[All lectures](http://galton.uchicago.edu/~burbank/stat224/lectures)