resplot {handyplots} | R Documentation |
Residual Plot
Description
Plot the fitted values vs the studentized or standardized residuals for a glm
or lm
object.
Usage
resplot(model, zoom = NULL, highlight.outliers = FALSE,
residuals = c("student","standard"))
Arguments
model |
a regression model with any number of predictors. Must be a |
zoom |
what range of residuals you wish to show in your plot. By default, zoom is |
highlight.outliers |
logical. If |
residuals |
which type of residuals to use. Studentized residuals are used by default, but can be specified with |
Details
A residual plot shows the fitted values of the response variable on the x-axis and the studentized or standardized residuals on the y-axis. It can be used to check for correlated residuals or non-constant variance of the residuals, both of which would violate the residual assumptions of a linear model. It can also be used to check for outliers, as a value below -3 or above 3 would indicate a residual which is more than 3 standard deviations from the mean of 0.
Author(s)
Jonathan Schwartz
References
Montgomery, D. C., Peck, E. A., Vining, G. G. (2013), Introduction to Linear Regression Analysis, Hoboken, NJ: John Wiley & Sons, Inc.
See Also
plot
,
abline
,
lm
,
glm
,
predict
,
rstudent
,
rstandard
Examples
##plot a residual plot to check the model assumptions for a linear
##model of iris petal length as a predicted by iris petal width
model<-lm(iris$Petal.Length~iris$Petal.Width)
resplot(model)
##highlight the one outlier
resplot(model,highlight.outliers=TRUE)
##zoom in to only show the residuals between -1 and 1
resplot(model,zoom=1)