An R Introduction to Statistics

Normal Probability Plot of Residuals

The normal probability plot is a graphical tool for comparing a data set with the normal distribution. We can use it with the standardized residual of the linear regression model and see if the error term ϵ is actually normally distributed.

Problem

Create the normal probability plot for the standardized residual of the data set faithful.

Solution

We apply the lm function to a formula that describes the variable eruptions by the variable waiting, and save the linear regression model in a new variable eruption.lm. Then we compute the standardized residual with the rstandard function.

> eruption.lm = lm(eruptions ~ waiting, data=faithful) 
> eruption.stdres = rstandard(eruption.lm)

We now create the normal probability plot with the qqnorm function, and add the qqline for further comparison.

> qqnorm(eruption.stdres, 
+     ylab="Standardized Residuals", 
+     xlab="Normal Scores", 
+     main="Old Faithful Eruptions") 
> qqline(eruption.stdres)

PIC

Note

Further detail of the qqnorm and qqline functions can be found in the R documentation.

> help(qqnorm)