plotGlm: Plot diagnostics for a binomial 'glm' model

Description Usage Arguments Value Note Examples

Description

Standard diagnostic plots.

Usage

1
2
3
4
5
## S3 method for class 'glm'
plot(x, y = NULL, ..., toPdf = FALSE, file = "dxPlots.pdf",
  palette = c("Dark2", "Set2", "Accent", "Blues"), usePalette = TRUE,
  bg = NULL, col = "white", alpha = 0.4, cex = 2, pch = 21,
  cex.main = 1.5, inches = 0.25, identify = FALSE, devNew = TRUE)

Arguments

x

A regression model with class glm and x$family$family == "binomial".

y

Not used. Present for compatibility with generic plot() function.

...

Additional arguments, which can be passed to the plotting functions. See:
?graphics::plot.default
?graphics::symbols
?graphics::par

toPdf
  • If toPdf=TRUE the output will be directed to a .pdf file.

  • If toPdf=FALSE a new device is opened for each plot.

file

Filename if writing to .pdf as above, e.g. "plots.pdf".

palette

Palette of colors to use as the 'fill'/ 'background' colors for the plots.
The options are taken from color_brewer.

usePalette

Use the colorscheme in palette above.

  • If usePalette=TRUE (the default), this colorscheme will be passed to the argument bg below:

    • graphics::plot.default(bg= )

    • graphics::symbols(bg= )

  • If usePalette=FALSE, then the color specified in bg below will be used instead.

bg

The 'fill' or background color(s) to use, if usePalette=FALSE.
This can be a vector of colors.

col

The 'edge' or 'foreground' color used to outline points in the plot.
The default, "white" is used to make overlapping points easier to see.
This is passed as an argument to

  • graphics::plot.default(col= )

  • graphics::symbols(fg= )

alpha

Transparency for colors above.
Should be in the range 0 (transparent) to 1 (opaque). See:
?grDevices::adjustcolor

cex

Character expansion.
A multiplier used for size of the plotting symbols/ characters. See:
?graphics::par

pch

Plotting character.
The symbol/ character to for the plot.
The default, pch=21 shows filled circles at each point. See:
?graphics::points

cex.main

Character expansion for the plot title and the labels for the axes.

inches

Width of circles for the bubble plot. See
?graphics::symbols

identify

If TRUE will give option to identify individual points on a number of the plots produced.
The number which appears next to the point corresponds to the relevant row as given by dx.
This may be useful for identifying outliers. See:
?graphics::identify

devNew

If devNew==TRUE (the default), dev.new will be called before each plot.
This is useful in interactive mode.
devNew==FALSE is used for vignette building by package:knitr.

Value

There is one point per observation.

The following show probability P[i] on the x-axis:

P[i] vs. h[i]

Probability vs. leverage.

P[i] vs. dChisq[i]

Probability vs. the change in the standardized Pearsons chi-squared with observation i excluded.

P[i] vs. dDev[i]

Probability vs. the change in the standardized deviance with observation i excluded.

P[i] vs. dBhat[i]

Probability vs. the change in the standardized maximum likelihood estimators of the model coefficients with observation i excluded.

P[i] vs. dChisq[i]

Bubbleplot of probability vs. the change in the standardized Pearsons chi-squared with observation i excluded.
The area A[i] of each circle is proportional to dBhat[i]:

A[i] = pi r[i]^2, r[i] = (dBhat[i] / P[i])^0.5

For details see:
?graphics::symbols

The following show leverage h[i] on the x-axis:

h[i] vs. dChisq[i]

Leverage vs. the change in the standardized Pearsons chi-squared with observation i excluded.

h[i] vs. dDev[i]

Leverage vs. the change in the standardized deviance with observation i excluded.

h[i] vs. dBhat[i]

Leverage vs. the change in the standardized maximum likelihood estimators of the model coefficients with observation i excluded.

The correlation of dChisq, dDev and dBhat. is shown in a pairs plot. See:
?graphics::pairs

The Value of dx is also returned, invisibly.

Note

A choice of colors can be found with e.g.
grDevices::colours()[grep("blue", grDevices::colours())]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## H&L 2nd ed. Table 4.9. Figures 5.5-5.8. Pages 177-180.
data(uis)
uis <- within(uis, {
    NDRGFP1 <- 10 / (NDRGTX + 1)
    NDRGFP2 <- NDRGFP1 * log((NDRGFP1 + 1) / 10)
})
summary(g1 <- glm(DFREE ~ AGE + NDRGFP1 + NDRGFP2 + IVHX +
                  RACE + TREAT + SITE +
                  AGE:NDRGFP1 + RACE:SITE,
                  family=binomial, data=uis))
plot(g1)
## H&L. Similar to Figure 5.3.
set.seed(133)
(g1 <- glm(sample(c(0, 1), size=100,
                  replace=TRUE, prob=c(0.5, 0.5))
           ~ 0 + I(0.08 * rnorm(n=100, mean=0, sd=sqrt(9))),
           family=binomial))$coef # approx. 0.8
plot(g1)

dardisco/LogisticDx documentation built on May 12, 2017, 5:37 p.m.