Learn R Programming

SMPracticals (version 1.4-3.1)

plot.glm.diag: Diagnostic plots for generalized linear models

Description

Makes plot of jackknife deviance residuals against linear predictor, normal scores plots of standardized deviance residuals, plot of approximate Cook statistics against leverage/(1-leverage), and case plot of Cook statistic.

Usage

# S3 method for glm.diag
plot(x, glmdiag = glm.diag(x), subset = NULL, iden = FALSE, 
                        labels = NULL, ret = FALSE, ...)

Value

If ret is TRUE then the value of glmdiag is returned otherwise there is no returned value.

Arguments

x

glm.object or lm.object : the result of a call to glm() or lm()

glmdiag

Diagnostics of x obtained from a call to glm.diag. If it is not supplied then it is calculated.

subset

Subset of data for which glm fitting performed: should be the same as the subset option used in the call to glm() or lm() which generated x. Needed only if the subset= option was used in the call to glm or lm.

iden

A logical argument. If TRUE then, after the plots are drawn, the user will be prompted for an integer between 0 and 4. A positive integer will select a plot and invoke identify() on that plot. After exiting identify(), the user is again prompted, this loop continuing until the user responds to the prompt with 0. If iden is FALSE (default) the user cannot interact with the plots.

labels

A vector of labels for use with identify() if iden is TRUE. If it is not supplied then the labels are derived from x.

ret

A logical argument indicating if glmdiag should be returned. The default is FALSE.

...

Other arguments, which are ignored. This is included only for compatibility with S3 methods.

Author

Angelo Canty

Details

The plot on the top left is a plot of the jackknife deviance residuals against the fitted values.

The plot on the top right is a normal QQ plot of the standardized deviance residuals. The dotted line is the expected line if the standardized residuals are normally distributed, i.e. it is the line with intercept 0 and slope 1.

The bottom two panels are plots of the Cook statistics. On the left is a plot of the Cook statistics against the standardized leverages. In general there will be two dotted lines on this plot. The horizontal line is at 8/(n-2p) where n is the number of observations and p is the number of parameters estimated. Points above this line may be points with high influence on the model. The vertical line is at 2p/(n-2p) and points to the right of this line have high leverage compared to the variance of the raw residual at that point. If all points are below the horizontal line or to the left of the vertical line then the line is not shown.

The final plot again shows the Cook statistic this time plotted against case number enabling us to find which observations are influential.

Use of iden=T is encouraged for proper exploration of these four plots as a guide to how well the model fits the data and whether certain observations have an unduly large effect on parameter estimates.

References

Davison, A.C. and Snell, E.J. (1991) Residuals and diagnostics. In Statistical Theory and Modelling: In Honour of Sir David Cox. D.V. Hinkley, N. Reid, and E.J. Snell (editors), 83-106. Chapman and Hall.

See Also

glm,glm.diag,identify

Examples

Run this code
  # leukaemia data
require(MASS)
data(leuk, package="MASS")
leuk.mod <- glm(time~ag-1+log10(wbc),family=Gamma(log),data=leuk)
leuk.diag <- glm.diag(leuk.mod)
plot.glm.diag(leuk.mod,leuk.diag)

Run the code above in your browser using DataLab