plot.regr {regr0}R Documentation

Diagnostic Plots for Regr Objects

Description

Diagnostic plots for fitted regression models: Residuals versus fit (Tukey-Anscombe plot) and/or target variable versus fit; Absolute residuals versus fit to assess equality of error variances; Normal Q-Q plot (for ordinary regression models); Residuals versus leverages to identify influential observations; Residuals versus sequence (if requested); and residuals versus explanatory variables. These plots are adjusted to the type of regression model.

Usage

## S3 method for class 'regr'
plot(x, data = NULL, plotselect = NULL, xplot = TRUE,
  rawvars = TRUE, sequence = FALSE, weights = NULL, addcomp = FALSE,
  smooth.legend = FALSE, ...)

plresx(x, data = NULL, vars = NULL, formula = NULL,
  rawvars = TRUE, sequence = FALSE, weights = NULL, addcomp = FALSE,
  smooth.legend = FALSE, ...)

Arguments

x

regr object (result of a call to regr). Thiw iw the only argument that is needed. All others have useful defaults.

data

data set where explanatory variables and the following possible arguments are found: weights, plweights, pch, plabs

plotselect

which plots should be shown? See Details

xplot, vars

if TRUE, residuals will be plotted versus all (raw) explanatory variables in the model (by calling plresx). If it is a formula, it contains the variables to be used. These need not be contained in the model. The model formula is updated by such a formula. Whence, the use of \~{}.+ adds variables to those in the model.

formula

same as vars. If both arguments are given, formula is used.

rawvars

logical: should residuals be shown against raw explanatory variables? If FALSE, the variables are transformed as implied by the model.

sequence

if TRUE, residuals will be plotted versus the sequence as they appear in the data. If another explanatory variable is monotone increasing or decreasing, the plot is not shown, but a warning is given.

weights

if TRUE, residuals will be plotted versus x$weights. Alternatively, a vector of weights can be specified

addcomp

logical: should component effects be added to residuals for residuals versus input variables plots?

smooth.legend

When a grouping factor is used (argument smooth.group, see below), this argument determines whether and where the legend for identifying the groups should be shown.

...

Many further arguments are available to customize the plots, see below for some of the most useful ones, and plotregrControl for a complete list.

Details

Argument plotselect is used to determine which plots will be shown. It should be a named vector of numbers indicating

0

do not show

1

show without smooth

2

show with smooth

The default is c( yfit=0, ta=3, tascale = NA, weights = NA, qq = NA, leverage = 2, resmatrix = 1, qqmult = 3).

Modify this vector to change the selection and the sequence in which the plots appear. Alternatively, provide a named vector defining all plots that should be shown on a different level than the default indicates, like plotselect = c(ta = 2, leverage = 1). Adding an element default = 0 suppresses all plots not mentioned. This is useful to select single plots, like plotselect = c(ta = 2, default = 0)

The names of plotselect refer to:

yfit

response versus fitted values

ta

residuals versus fitted values (Tukey-Anscombe plot)

tascale

residuals versus fitted values, defaults to TRUE for ordinary regression, FALSE for glm and others

weights

residuals versus weights

qq

normal Q-Q plot, defaults to TRUE for ordinary regression, FALSE for glm and others

leverage

residuals versus leverage (hat diabgonal)

resmatrix

scatterplot matrix of residuals for multivariate regression

qqmult

qq plot for Mahlanobis lengths versus sqrt of chisquare quantiles.

In the Tukey-Anscombe plot, the reference line indicates a "contour" line with constant values of the response variable, Y=\widehat y+r= constant. It has slope -1. It is useful to judge whether any curvature shown by the smooth might disappear after a nonlinear, monotone transformation of the response.

If smresid is true, the 'tascale' plot uses modified residuals: differences between the ordinary residuals and the smooth appearing in the 'ta' plot. Analogously, the 'qq' plot is then based on yet another modification of these modified residuals: they are scaled by the smoothed scale shown in the 'tascale' plot, after these scales have been standardized to have a median of 0.674 (=qnorm(0.75)).

The smoothing function used by default is smoothRegr, which calls loess. This can be changed by setting userOptions(smoothFunction=<func>), which must have the same arguments as smoothRegr.

The arguments lty, lwd, colors characterize how the graphical elements in the plot are shown. They should be three vectors of length 9 each, defining the line types, line widths, and colors to be used for ...

[1]

observations;

[2]

reference lines;

[3]

smooth;

[4]

simulated smooths;

[5]

component effects in plresx;

[6]

confidence bands of component effects.

In the case of glm.restype="cond.quant"

[7]

(random) observations;

[8]

conditional medians;

[9]

bars showing conditional quantiles.

Value

The list of the evaluations of all arguments and some more useful items is returned invisibly.

Note

This is a function under development. Future versions may behave differently and may not be compatible with this version.

Author(s)

Werner A. Stahel, ETH Zurich

See Also

plotregrControl, plot.lm

Examples

  r.savings <- regr(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)
  plot(r.savings)

  data(d.blast)
  r.blast <-
       regr(log10(tremor)~location+log10(distance)+log10(charge),
            data=d.blast)
  plot(r.blast, sequence=TRUE, rawvars=FALSE) 

  data(d.fossiles)
  r.foss <-
    regr(cbind(sAngle,lLength,rWidth)~SST.Mean+Salinity+lChlorophyll+region+N,
    data=d.fossiles)
  plot(r.foss, plotselect=c(ta=3, resmatrix=1, qqmult=1),xplot=FALSE)

[Package regr0 version 1.0-5 Index]