Component+Residual (Partial Residual) Plots
These functions construct component+residual plots (also called partial-residual plots) for linear and generalized linear models.
crPlots(model, terms = ~., layout = NULL, ask, main, ...) crp(...) crPlot(model, ...) ## S3 method for class 'lm': crPlot(model, variable, id.method = list(abs(residuals(model, type="pearson")), "x"), labels, id.n = if(id.method=="identify") Inf else 0, id.cex=1, id.col=palette(), order=1, line=TRUE, smoother=loessLine, smoother.args=list(), smooth, span, col=palette(), col.lines=palette()[-1], xlab, ylab, pch=1, lwd=2, grid=TRUE, ...)
- model object produced by
- A one-sided formula that specifies a subset of the predictors.
One component-plus-residual plot is drawn for each term. The default
~.is to plot against all numeric predictors. For example, the specification
terms = ~ . - X3
- If set to a value like
c(4, 3), the layout of the graph will have this many rows and columns. If not set, the program will select an appropriate layout. If the number of graphs exceed nine, you must select the la
TRUE, ask the user before drawing the next plot; if
FALSE, the default, don't ask. This is relevant only if not all the graphs can be drawn in one window.
- The title of the plot; if missing, one will be supplied.
crPlotspasses these arguments to
crPlotpasses them to
- A quoted string giving the name of a variable for the horizontal axis
- Arguments for the labelling of
points. The default is
id.n=0for labeling no points. See
showLabelsfor details of these arguments.
- order of polynomial regression performed for predictor to be plotted; default
TRUEto plot least-squares line.
- Function to add a nonparametric smooth.
ScatterplotSmoothersfor available smooethers and arguments.
- smooth, span
- these arguments are included for backwards compatility:
smootheris set to
loessLine, and if
spanis specified, it is added to
- color for points; the default is the first entry
in the current color palette (see
- a list of at least two colors. The first color is used for the
ls line and the second color is used for the fitted lowess line. To use
the same color for both, use, for example,
- labels for the x and y axes, respectively. If not set appropriate labels are created by the function.
- plotting character for points; default is
1(a circle, see
- line width; default is
- If TRUE, the default, a light-gray background grid is put on the graph
The function intended for direct use is
crPlots, for which
is an abbreviation.
The model cannot contain interactions, but can contain factors.
Parallel boxplots of the partial residuals are drawn for the levels
of a factor.
NULL. These functions are used for their side effect of producing plots.
Cook, R. D. and Weisberg, S. (1999) Applied Regression, Including Computing and Graphics. Wiley. Fox, J. (2008) Applied Regression Analysis and Generalized Linear Models, Second Edition. Sage. Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage.
crPlots(m<-lm(prestige~income+education, data=Prestige)) # get only one plot crPlots(m, terms=~ . - education) crPlots(lm(prestige ~ log2(income) + education + poly(women,2), data=Prestige)) crPlots(glm(partic != "not.work" ~ hincome + children, data=Womenlf, family=binomial))