Last class period we went over several different topics, the first of which was different ways of analyzing residuals.

The first way was through the residual plot. This is used to look for trends in our residuals. This would indicate that we are missing something for our mean function. Second was through the QQnorm plot. This plot uses studentized residuals, rather than normal residuals to give us a better look at the trends that might exist. Third was through the Scale location plot. This plot is used for the same things as the last two with the benifit that it aids us in removing some of the skewedness of our data. Lastly, we used the Cook’s distance. This plot is a measure of how much influence each point has on the corrilation coefficient.

Below is the code to get all 4 plots. More specificaly, if you were to use the code plot(yourmodelhere) it will plot all 4 for you.

library(alr3)
## Loading required package: car
data(brains)
attach(brains)

mod <- lm(BodyWt ~ BrainWt)

plot(mod)

Also, we went over a few transformations we could use on our data. The transforms we went over included y^.5, log(y), and 1/y. y^.5 helps reduce a datas heteroscedasticity. log(y) is also used for this, with the added acception that all the datapoints much be >0. Lastly, 1/y is used if you have some previous knowladge that the data has an inverse relationship.

another useful code we got in class today was

par(mfrow = c(2,2))  #used to plot 2 by 2 plots on screen
plot(mod)

which allows us to look at several graphs at once.