Learn R Programming

binomTools (version 1.0-1)

halfnorm: Half normal plot with simulated envelopes

Description

halfnorm produces a half normal plot of the residuals with simulated envelopes useful for model evaluation and detection of outliers

Usage

halfnorm(object, resType = c("approx.deletion", "exact.deletion", "standard.deviance", "standard.pearson", "deviance", "pearson", "working", "response", "partial"), env = T, nsim = 20, plot = T, identify = F, n = 2)

Arguments

object
An object of class glm with a binomial family
resType
The type of residual used in the plot
env
Logical for whether envelopes are simulated
nsim
Number of simulations used for the envelopes
plot
Logical for whether the points should be plotted. If plot = F a list is returned
identify
Logical for whether it should be possible to identify points interactively. Ignored if plot = F
n
How many points should be identified. Ignored if identify = F

Value

If plot = T a plot is produced. Otherwise a list of the residuals and their expected values are returned

Details

Absolute values of the residuals are used in a half normal plot that otherwise corresponds to a regular normal probability plot.

Residuals from a binomial glm are not necessarily uncorrelated and normally distributed and may accordingly deviate from a straight line even if the fitted model is true. If the fitted model is true the optional simulated envelopes are likely to contain the absolute residuals.

The different types of residuals are described in Residuals

References

Atkinson, A. C. (1981) Two graphical displays for outlying and influential observations in regression. Biometrika, 68, 13-20.

Collett, D. (2003) Modelling binary data. Second edition. Chapman & Hall/CRC.

See Also

Residuals, identify

Examples

Run this code
## Halfnormal plot with simulated envelopes
data(beetles)
beetles.glm <- glm(cbind(y, n-y) ~ conc, family=binomial, data=beetles)
halfnorm(beetles.glm, resType='pearson')

## Not run: 
# ## Halfnormal plot with simulated envelopes
# ## Two points are interactively identified when they are selected with the mouse
# halfnorm(beetles.glm, resType='deviance', identify = T, n = 2)
# ## End(Not run)

Run the code above in your browser using DataLab