residuals.glm
Compute Residuals for glm Objects

Description

Computes one of the four types of residuals available for glm objects.

Usage

residuals.glm(object, type = c("deviance", "pearson", "working", 
    "response", "partial"), ...) 

Arguments

object an object inheriting from class "glm" representing a fitted model.
type type of residuals, with choices "deviance", "pearson", "working", "response" or "partial"; the first is the default.
... further arguments passed to or from other methods
Value
A numeric vector of residuals. See Statistical Models in Sfor detailed definitions of each type of residual. The sum of squared deviance residuals add up to the deviance. The pearson residuals are standardized residuals on the scale of the response. The working residuals reside on the object, and are the residuals from the final IRLS fit. The response residuals are simply y-fitted(object). The partial residuals are the working residuals plus the prediction of object in terms type. The summary() method for glm objects produces deviance residuals. The residuals component of a glm object contains the working residuals.
Note
This is a method for the function residuals() for objects inheriting from class "glm". However, as several types of residuals are available for glm objects, there is an additional optional argument type.
residuals() will use naresid to handle missing values (NAs) in residuals with na.action of object.
References
Chambers, J. M. and Hastie, T .J. (Eds.) 1991. Statistical Models in S. Pacific Grove, CA.: Wadsworth & Brooks/Cole. 204-206.
Chambers, J. M. and Hastie, T .J. (Eds.) 1992. Statistical Models in S. Pacific Grove, CA.: Wadsworth & Brooks/Cole.
See Also
glm.object, coefficients, naresid, predict.
Examples
ldose <- rep(0:5, 2)
numdead <- c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)
sex <- factor(rep(c("M", "F"), c(6, 6)))
SF <- cbind(numdead, numalive = 20 - numdead)
budworm.lg <- glm(SF ~ sex*ldose, family = binomial)
residuals(budworm.lg, type = "partial")
residuals(budworm.lg)
residuals(budworm.lg, type = "response")
Package stats version 6.1.1-7
Package Index