residual.plots {alr3} | R Documentation |
Plots the residuals versus each term in a mean function and versus fitted values. Also computes a curvature test for each of the plots by adding a quadratic term and testing the quadratic to be zero. This is Tukey's test for nonadditivity when plotting against fitted values.
### This is a generic function with only one required argument: residual.plots (m, ...) ### When the first argument is a linear model (of class lm), the form of the ### function is ## S3 method for class 'lm' residual.plots(m,vars=~.,fitted=TRUE,plot=TRUE, layout=NULL,ask,...) ### The following are three related functions: resplot(m,varname="tukey",type="pearson", plot=TRUE,add.quadratic=TRUE, ylab=paste(string.capitalize(type),"Residuals"),...) resid.curv.test(m,varname) tukey.nonadd.test(m)
m |
|
vars |
A one-sided formula that specifies a subset of the predictors.
One
residual plot is drawn for each column specified. The default
|
fitted |
If TRUE, the default, plot against fitted values. |
tukey |
If TRUE, draw plot of residuals versus fitted values and compute Tukey's test of non-additivity. |
layout |
If set to a value like |
ask |
If TRUE, ask the user before drawing the next plot; FALSE if don't ask. |
... |
|
varname |
Quoted variable name for the horizontal axis,
|
type |
Type of residuals to be used. Pearson residuals are
appropriate for |
ylab |
Label for the yaxis. The default is the residual type. |
add.quadratic |
if TRUE, fits the quadratic regression of the vertical axis on the horizontal axis. |
plot |
If TRUE, draw the plot(s). |
residual.plots
draws all residuals plots, versus
each term specified first-order term in the model (interactions are
automatically skipped) and versus fitted values, and returns all the
curvature tests. resplot
, which is called by residual.plots
,
should be viewed as an internal function, and is included here to display its
arguments, which can be used with residual.plots
as well.
resid.curv.test
computes the curvature test only. For any factors a
boxplot will be drawn.
Returns a data.frame with one row for each plot drawn, one column for the curvature test statistic, and a second column for the corresponding p-value. This function is used primarily for its side effect of drawing residual plots.
Sanford Weisberg, sandy@stat.umn.edu
S. Weisberg (2005), Applied Linear Regression, third edition, Wiley, Chapter 8
See Also lm
data(highway) highway$Sigs <- (round(highway$Sigs*highway$Len)+1)/highway$Len attach(highway) d <- data.frame(Rate=Rate,logLen=logb(Len,2), logADT=logb(ADT,2),logTrks=logb(Trks,2), Slim=Slim,Shld=Shld,logSigs1=logb(Sigs,2)) attach(d) m2 <- lm(Rate~logLen+logADT+logTrks+Slim+Shld+logSigs1,d) residual.plots(m2)