R: Plot Diagnostics for a gnm Object

plot.gnm {gnm} | R Documentation

## Plot Diagnostics for a gnm Object

### Description

Five plots are available: a plot of residuals against fitted values, a Scale-Location plot of sqrt{| residuals |} against fitted values, a Normal Q-Q plot, a plot of Cook's distances versus row labels, and a plot of residuals against leverages. By default, all except the fourth are produced.

### Usage

    ## S3 method for class 'gnm'
    plot(x, which = c(1:3, 5), caption = c("Residuals vs Fitted",
             "Normal Q-Q", "Scale-Location", "Cook's distance",
             "Residuals vs Leverage"),
             panel = if (add.smooth) panel.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,
             qqline = TRUE, cook.levels = c(0.5, 1),
             add.smooth = getOption("add.smooth"), label.pos = c(4, 2),
             cex.caption = 1)

### Arguments

`x` | a `"gnm"` object.
`which` | a subset of the numbers 1:5 specifying which plots to produce (out of those listed in Description section).
`caption` | captions to appear above the plots.
`panel` | panel function. The useful alternative to `points`, `panel.smooth` can be chosen by `add.smooth = TRUE`.
`sub.caption` | common title - above figures if there are multiple; used as `sub` (s.`title`) otherwise. If `NULL`, as by default, a possible shortened version of `deparse(x$call)` is used.
`main` | title to each plot - in addition to the above `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.
`qqline` | logical indicating if a `qqline()` should be added to the normal Q-Q plot.
`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.
`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'.

### Details

`sub.caption` - by default the function call - is shown as a subtitle (under the x-axis title) on each plot when plots are on separate pages, or as a subtitle in the outer margin (if any) when there are multiple plots per page.

The "Scale-Location" plot, also called "Spread-Location" or "S-L" plot, takes the square root of the absolute residuals in order to diminish skewness (sqrt{| E |} is much less skewed than | E | for Gaussian zero-mean E).

The S-L, the Q-Q, and the Residual-Leverage plot, use standardized residuals which have identical variance (under the hypothesis). They are given as R[i] / (s*sqrt(1 - h.ii)) where h.ii are the diagonal entries of the hat matrix, `influence()$hat`, see also `hat`.

The Residual-Leverage plot shows contours of equal Cook's distance, for values of `cook.levels` (by default 0.5 and 1) and omits cases with leverage one. If the leverages are constant, as typically in a balanced `aov` situation, the plot uses factor level combinations instead of the leverages for the x-axis.

### Author(s)

Modification of `plot.lm` by the R Core Team. Adapted for `"gnm"` objects by Heather Turner.

### See Also

`gnm`, `plot.lm`

### Examples

    set.seed(1)

    ##  Fit an association model with homogeneous row-column effects
    RChomog <- gnm(Freq ~ origin + destination + Diag(origin, destination) +
                   MultHomog(origin, destination), family = poisson,
                   data = occupationalStatus)

    ## Plot model diagnostics
    plot(RChomog)

    ## Put 4 plots on 1 page; allow room for printing model formula in outer margin:
    par(mfrow = c(2, 2), oma = c(0, 0, 3, 0))
    title <- paste(deparse(RChomog$formula, width.cutoff = 50), collapse = "\n")
    plot(RChomog, sub.caption = title)

    ## Fit smoother curves
    plot(RChomog, sub.caption = title, panel = panel.smooth)
    plot(RChomog, sub.caption = title, panel = function(x,y) panel.smooth(x, y, span = 1))

[Package gnm version 1.1-2 Index]