plot.zlm {complexlm}R Documentation

Plot Diagnostics for a Complex Linear Model Objects

Description

A modified version of stats::plot.lm used for visualizing ordinary ("zlm") and robust ("rzlm") linear models of complex variables. This documentation entry describes the complex version, focusing on the differences and changes from the numeric. For further explanation of the plots please see stats::plot.lm.

Usage

## S3 method for class 'zlm'
plot(
  x,
  which = c(1, 3, 5),
  caption = list("Residuals vs Fitted", "Scale-Location", "Cook's distance",
    "Residuals vs Leverage", expression("Cook's dist vs Leverage  " * h[ii]/(1 - h[ii]))),
  panel = if (add.smooth) function(x, y, ...) panel.smooth(x, y, iter = iter.smooth,
    ...) else points,
  sub.caption = NULL,
  main = "",
  ask = prod(par("mfcol")) < length(which) && dev.interactive(),
  ...,
  id.n = 3,
  labels.id = names(residuals(x)),
  cex.id = 0.75,
  cook.levels = c(0.5, 1),
  add.smooth = getOption("add.smooth"),
  iter.smooth = if (isGlm) 0 else 3,
  label.pos = c(4, 2),
  cex.caption = 1,
  cex.oma.main = 1.25
)

Arguments

x

complex lm object ("zlm" or "rzlm"). Typically produced by lm or rlm.

which

If a subset of the plots is required, specify a subset of the numbers 1:6, except 2. See stats::plot.lm, and below, for the different kinds. Default is c(1,3,5).

caption

captions to appear above the plots; character vector or list of valid graphics annotations, see as.graphicsAnnot, of length 6, the j-th entry corresponding to which[j]. Can be set to "" or NA to suppress all captions.

panel

panel function. The useful alternative to points, panel.smooth can be chosen by add.smooth = TRUE.

sub.caption

common title—above the figures if there are more than one; used as sub (s.title) otherwise. If NULL, as by default, a possible abbreviated version of deparse(x$call) is used.

main

title to each plot—in addition to caption.

ask

logical; if TRUE, the user is asked before each plot, see par(ask=.).

...

other parameters to be passed through to plotting functions.

id.n

number of points to be labelled in each plot, starting with the most extreme.

labels.id

vector of labels, from which the labels for extreme points will be chosen. NULL uses observation numbers.

cex.id

magnification of point labels.

cook.levels

levels of Cook's distance at which to draw contours.

add.smooth

logical indicating if a smoother should be added to most plots; see also panel above.

iter.smooth

the number of robustness iterations, the argument iter in panel.smooth(); the default uses no such iterations for glm fits which is particularly desirable for the (predominant) case of binary observations, but also for other models where the response distribution can be highly skewed.

label.pos

positioning of labels, for the left half and right half of the graph respectively, for plots 1-3.

cex.caption

controls the size of caption.

cex.oma.main

controls the size of the sub.caption only if that is above the figures when there is more than one.

Details

Five of the six plots generated by stats::plot.lm can be produced by this function: The residuals vs. fitted values plot, the scale-location plot, the plot of Cook's distances vs. row labels, the plot of residuals vs. leverages, and the plot of Cook's distances vs. leverage/(1-leverage). The Q-Q plot is not drawn because it requires quantiles, which are not unambiguously defined for complex numbers. Because complex numbers are two dimensional, pairs is used to create multiple scatter plots of the real and imaginary components for the residuals vs. fitted values and scale-location plots.

Value

Several diagnostic plots.

References

Belsley, D. A., Kuh, E. and Welsch, R. E. (1980). Regression Diagnostics. New York: Wiley.

Cook, R. D. and Weisberg, S. (1982). Residuals and Influence in Regression. London: Chapman and Hall.

Firth, D. (1991) Generalized Linear Models. In Hinkley, D. V. and Reid, N. and Snell, E. J., eds: Pp. 55-82 in Statistical Theory and Modelling. In Honour of Sir David Cox, FRS. London: Chapman and Hall.

Hinkley, D. V. (1975). On power transformations to symmetry. Biometrika, 62, 101-111. doi: 10.2307/2334491.

McCullagh, P. and Nelder, J. A. (1989). Generalized Linear Models. London: Chapman and Hall.

See Also

zhatvalues, cooks.distance, lm, rlm

Examples

set.seed(4242)
n <- 8
slop <- complex(real = 4.23, imaginary = 2.323)
interc <- complex(real = 1.4, imaginary = 1.804)
e <- complex(real=rnorm(n)/6, imaginary=rnorm(n)/6)
xx <- complex(real= rnorm(n), imaginary= rnorm(n))
tframe <- data.frame(x = xx, y= slop*xx + interc + e)
fit <- lm(y ~ x, data = tframe, weights = rep(1,n))
plot(fit)

[Package complexlm version 1.1.2 Index]