plotres

0th

Percentile

Plot the residuals of a regression model

Plot the residuals of a regression model.

See the ../doc/plotres-notes.pdf{plotres} vignette.

Keywords
regression, partial dependence
Usage
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)), ...)
Arguments
object
The model object.
which
Which plots do draw. Default is 1:4.

1 Model plot. What gets plotted here depends on the model class. For example, for earth models this is a model selection plot. Nothing will be displayed for some models. For d

info
Default is FALSE. Use TRUE to print extra information as follows: 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

versus
What do we plot the residuals against? One of:

1 Default. Plot the residuals versus the fitted values (or the log values when which=7 to 9).

2 Residuals versus observation number, after observations h

standardize
Default is FALSE. Use TRUE to standardize the residuals. Only supported for some models, an error message will be issued otherwise. Each residual is divided by by se_i * sqrt(1 - h_ii), where se_i is th
delever
Default is FALSE. Use TRUE to de-lever the residuals. Only supported for some models, an error message will be issued otherwise. Each residual is divided by sqrt(1 - h_ii). See the standardize
level
Draw estimated confidence or prediction interval bands at the given level, if the model supports them. Default is 0, bands not plotted. Else a fraction, for example level=0.90. Example:mod <- lm(log(Volume)~log(Girt
id.n
The largest id.n residuals will be labeled in the plot. Default is 3. Special values TRUE and -1 or mean all. If id.n is negative (but not -1) the id.n most positiv
labels.id
Residual labels. Only used if id.n > 0. Default is the case names, or the case numbers if the cases are unnamed.
smooth.col
Color of the smooth line through the residual points. Default is 2, red. Use smooth.col=0 for no smooth line. You can adjust the amount of smoothing with smooth.f. This gets passed as f to
grid.col
Default is 0, no grid. Else add a background grid of the specified color to the degree1 plots. The special value grid.col=TRUE is treated as "lightgray".
jitter
Default is 0, no jitter. Passed as factor to jitter to jitter the plotted points horizontally and vertically. Useful for discrete variables and responses, where the residual poi
do.par
One of NULL, FALSE, TRUE, or 2, as follows:

do.par=NULL (default). Same as do.par=FALSE if the number of plots is one; else the same as TRUE.

do.par=FALSE

caption
Overall caption. By default create the caption automatically. Use caption="" for no caption. (Use main to set the title of an individual plot.)
trace
Default is 0. trace=1 (or TRUE) for a summary trace (shows how predict and friends are invoked for the model). trace=2 for detailed tracing.
npoints
Number of points to be plotted. A sample of npoints is taken; the sample includes the biggest twenty or so residuals. The default is 3000 (not all, to avoid overplotting on large models). Use npoints=TRUE or -1 for
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 residuals and if that fails to predict. For allowed values see the residuals and predict methods f
nresponse
Which column to use when residuals or predict returns multiple columns. This can be a column index or column name (which may be abbreviated, partial matching is used).
object.name
The name of the object for error and trace messages. Used internally by plot.earth.
...
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 arg

Note

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, and for further discussion please see Accessing the model data in the ../doc/plotmo-notes.pdf{plotmo} vignette.

Acknowledgments

The which=1 plot for glmnet models is based on code in the glmnet package by Jerome Friedman, Trevor Hastie, Noah Simon, and Rob Tibshirani.

The which=1 plot for gbm models is based on code in the gbm package by Greg Ridgeway with contributions from others.

concept

residual plot

See Also

Please see the ../doc/plotres-notes.pdf{plotres} vignette.

plot.lm

plot.earth

Aliases
  • plotres
Examples
# 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)
Documentation reproduced from package plotmo, version 3.0.0, License: GPL-3

Community examples

Looks like there are no examples yet.