car (version 2.0-1)

crPlots: Component+Residual (Partial Residual) Plots

Description

These functions construct component+residual plots (also called partial-residual plots) for linear and generalized linear models.

Usage

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[1]=="identify") Inf else 0,
  id.cex=1, id.col=palette()[1],
  order=1, line=TRUE, smooth=TRUE,
	iter, span=.5, las=par("las"), col=palette()[2], pch=1, lwd=2,
	grid=TRUE, ...)

## S3 method for class 'glm':
crPlot(model, ...)

Arguments

model
model object produced by lm or glm.
terms
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
layout
If set to a value like c(1,1) or 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 layo
ask
If 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.
main
The title of the plot; if missing, one will be supplied.
...
crPlots passes these arguments to crPlot. crPlot passes them to plot.
variable
A quoted string giving the name of a variable for the horizontal axis
id.method,labels,id.n,id.cex,id.col
Arguments for the labelling of points. The default is id.n=0 for labeling no points. See showLabels for details of these arguments.
order
order of polynomial regression performed for predictor to be plotted; default 1.
line
TRUE to plot least-squares line.
smooth
TRUE to plot nonparametric-regression (lowess) line.
iter
number of robustness iterations for nonparametric-regression smooth; defaults to 3 for a linear model and to 0 for a non-Gaussian glm.
span
span for lowess smoother.
las
if 0, ticks labels are drawn parallel to the axis; set to 1 for horizontal labels (see par).
col
color for points and lines; the default is the second entry in the current color palette (see palette and par).
pch
plotting character for points; default is 1 (a circle, see par).
lwd
line width; default is 2 (see par).
grid
If TRUE, the default, a light-gray background grid is put on the graph

Value

  • NULL. These functions are used for their side effect of producing plots.

Details

The function intended for direct use is crPlots, for which crp 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.

References

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.

See Also

ceresPlots, avPlots

Examples

Run this code
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))

Run the code above in your browser using DataCamp Workspace