avPlots {car} | R Documentation |
Added-Variable Plots
Description
These functions construct added-variable, also called partial-regression, plots for linear and generalized linear models.
Usage
avPlots(model, ...)
## Default S3 method:
avPlots(model, terms=~., intercept=FALSE,
layout=NULL, ask, main, ...)
avp(...)
avPlot(model, ...)
## S3 method for class 'lm'
avPlot(model, variable,
id=TRUE, col = carPalette()[1], col.lines = carPalette()[2],
xlab, ylab, pch = 1, lwd = 2, cex = par("cex"), pt.wts = FALSE,
main=paste("Added-Variable Plot:", variable),
grid=TRUE,
ellipse=FALSE,
marginal.scale=FALSE, ...)
## S3 method for class 'glm'
avPlot(model, variable,
id=TRUE,
col = carPalette()[1], col.lines = carPalette()[2],
xlab, ylab, pch = 1, lwd = 2, cex = par("cex"), pt.wts = FALSE,
type=c("Wang", "Weisberg"),
main=paste("Added-Variable Plot:", variable), grid=TRUE,
ellipse=FALSE, ...)
avPlot3d(model, coef1, coef2, id=TRUE, ...)
## S3 method for class 'lm'
avPlot3d(model, coef1, coef2, id=TRUE, fit="linear", ...)
## S3 method for class 'glm'
avPlot3d(model, coef1, coef2, id=TRUE, type=c("Wang", "Weisberg"),
fit="linear", ...)
Arguments
model |
model object produced by |
terms |
A one-sided formula that specifies a subset of the predictors.
One added-variable plot is drawn for each term. For example, the
specification |
coef1 , coef2 |
the quoted names of the two coefficients for a 3D added variable plot. |
intercept |
Include the intercept in the plots; default is |
variable |
A quoted string giving the name of a regressor in the model matrix for the horizontal axis. |
layout |
If set to a value like |
main |
The title of the plot; if missing, one will be supplied. |
ask |
If |
id |
controls point identification; if |
col |
color for points; the default is the second entry
in the current car palette (see |
col.lines |
color for the fitted line. |
pch |
plotting character for points; default is |
lwd |
line width; default is |
cex |
size of plotted points; default is taken from |
pt.wts |
if |
xlab |
x-axis label. If omitted a label will be constructed. |
ylab |
y-axis label. If omitted a label will be constructed. |
type |
if |
grid |
If |
ellipse |
controls plotting data-concentration ellipses. If |
marginal.scale |
Consider an added-variable plot of Y versus X given Z. If this argument is |
fit |
one or both of |
... |
|
Details
The functions intended for direct use are avPlots
(for which avp
is an abbreviation) and avPlot3d
.
Value
These functions are used for their side effect id producing plots, but also invisibly return the coordinates of the plotted points.
Author(s)
John Fox jfox@mcmaster.ca, Sanford Weisberg sandy@umn.edu
References
Cook, R. D. and Weisberg, S. (1999) Applied Regression, Including Computing and Graphics. Wiley.
Fox, J. (2016) Applied Regression Analysis and Generalized Linear Models, Third Edition. Sage.
Fox, J. and Weisberg, S. (2019) An R Companion to Applied Regression, Third Edition, Sage.
Wang, P C. (1985) Adding a variable in generalized linear models. Technometrics 27, 273–276.
Weisberg, S. (2014) Applied Linear Regression, Fourth Edition, Wiley.
See Also
residualPlots
, crPlots
, ceresPlots
, link{dataEllipse}
, showLabels
, dataEllipse
.
Examples
avPlots(lm(prestige ~ income + education + type, data=Duncan))
avPlots(glm(partic != "not.work" ~ hincome + children,
data=Womenlf, family=binomial), id=FALSE, pt.wts=TRUE)
m1 <- lm(partic ~ tfr + menwage + womwage + debt + parttime, Bfox)
par(mfrow=c(1,3))
# marginal plot, ignoring other predictors:
with(Bfox, dataEllipse(womwage, partic, levels=0.5))
abline(lm(partic ~ womwage, Bfox), col="red", lwd=2)
# AV plot, adjusting for others:
avPlots(m1, ~ womwage, ellipse=list(levels=0.5))
# AV plot, adjusting and scaling as in marginal plot
avPlots(m1, ~ womwage, marginal.scale=TRUE, ellipse=list(levels=0.5))
# 3D AV plot, requires the rgl package
if (interactive() && require("rgl")){
avPlot3d(lm(prestige ~ income + education + type, data=Duncan),
"income", "education")
}