Plot the residuals of a regression model
Plot the residuals of a regression model.
Please see the plotres vignette (also available here).
plotres(object = stop("no 'object' argument"), which = 1:4, info = FALSE, versus = 1, standardize = FALSE, delever = FALSE, level = 0, id.n = 3, labels.id = NULL, smooth.col = 2, grid.col = 0, jitter = 0, do.par = NULL, caption = NULL, trace = 0, npoints = 3000, center = TRUE, type = NULL, nresponse = NA, object.name = quote.deparse(substitute(object)), ...)
object |
The model object. |
which |
Which plots do draw. Default is
|
info |
Default is i) Display the distribution of the residuals along the bottom of the plot. ii) Display the training R-Squared. iii) Display the Spearman Rank Correlation of the absolute residuals
with the fitted values.
Actually, correlation is measured against the absolute values
of whatever is on the horizontal
axis — by default this is the fitted response, but may be something
else if the iv) In the Cumulative Distribution plot ( v) Only for vi) Add various annotations to the other plots.
|
versus |
What do we plot the residuals against? One of:
Else a character vector specifying which predictors to plot against.
|
standardize |
Default is |
delever |
Default is |
level |
Draw estimated confidence or prediction interval bands at the given
mod <- lm(log(Volume)~log(Girth), data=trees) plotres(mod, level=.90) You can modify the color of the bands with |
id.n |
The largest |
labels.id |
Residual labels.
Only used if |
smooth.col |
Color of the smooth line through the residual points.
Default is |
grid.col |
Default is |
jitter |
Default is |
||||||||||||||||||||||||||||
do.par |
One of
|
||||||||||||||||||||||||||||
caption |
Overall caption. By default create the caption automatically.
Use |
||||||||||||||||||||||||||||
trace |
Default is |
||||||||||||||||||||||||||||
npoints |
Number of points to be plotted.
A sample of |
||||||||||||||||||||||||||||
center |
Default is TRUE, meaning center the horizontal axis in the residuals plot, so asymmetry in the residual distribution is more obvious. |
||||||||||||||||||||||||||||
type |
Type parameter passed first to |
||||||||||||||||||||||||||||
nresponse |
Which column to use when |
||||||||||||||||||||||||||||
object.name |
The name of the |
||||||||||||||||||||||||||||
... |
Dot arguments are passed to the plot functions. Dot argument names, whether prefixed or not, should be specified in full and not abbreviated. “Prefixed” arguments are passed directly to the associated function.
For example the prefixed argument
The For backwards compatibility, some dot arguments are supported but not explicitly documented. |
If the which=1
plot was plotted, the return value of that
plot (model dependent).
Else if the which=3
plot was plotted, return list(x,y)
where x
and y
are the coordinates of the points in that plot
(but without jittering even if the jitter
argument was used).
Else return NULL
.
This function is designed primarily for displaying standard
response - fitted
residuals for models
with a single continuous response,
although it will work for a few other models.
In general this function won't work on models that don't save the call
and data with the model in a standard way.
It uses the same underlying mechanism to access the model data as
plotmo
.
For further discussion please see “Accessing the model
data” in the plotmo vignette
(also available here).
Package authors may want to look at
Guidelines for S3 Regression Models
(also available here).
Please see the plotres vignette (also available here).
# we use lm in this example, but plotres is more useful for models # that don't have a function like plot.lm for plotting residuals lm.model <- lm(Volume~., data=trees) plotres(lm.model)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.