The first step in most diagnostic analyses is to compute the residuals
\begin{block}{Residuals} The vertical distance from our measurements to the regression line are called the \textbf{residuals} and are denoted with $\hat e$. The size of the residuals can be calculated with \[ \hat e_i = y_i - \hat{y}_i \] Points above the regression line have a positive residue but points below it have a negative. \end{block}
Examples
{\bf Example - beers}
We will continue to use the beer data. \begin{verbatim} beers<-c(5,2,9,7,3,3,4,5,8,3,5,5,6,7,1,4) alcohol<-c(0.1,0.03,0.19,0.095,0.07,0.02,0.07,0.085,0.12,0.04,0.06,0.05,0.1,0.09,0.01,0.05) \end{verbatim}
We use the lm() function to fit the data \begin{verbatim} fit<-lm(alcohol~beers) \end{verbatim} We use the residual() function to get the residuals: \begin{verbatim} residuals(fit) \end{verbatim}