Compute Residuals for glm Objects

DESCRIPTION:

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

USAGE:

residuals.glm(object, type) 

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.

REQUIRED ARGUMENTS:

object
an object inheriting from class "glm" representing a fitted model.

OPTIONAL ARGUMENTS:

type
type of residuals, with choices "deviance", "pearson", "working" or "response"; the first is the default.

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 summary() method for glm objects produces deviance residuals. The residuals component of a glm object contains the working residuals.

REFERENCES:

Chambers, J.M., and Hastie, T.J. (1991). Statistical Models in S, pp. 204--206.

SEE ALSO:

, , .

EXAMPLES:

kyph.glm <- glm(Kyphosis ~ ., binomial, kyphosis) 
plot(fitted(kyph.glm), resid(kyph.glm, type = "response"), ylab = 
        "response residuals") 
#produce a matrix of partial residuals, one column for each term 
kyph.predict <- predict(kyph.glm, type = "terms") + kyph.glm$residuals 
par(mfrow=c(1,3)) 
plot(kyphosis$Age, kyph.predict[, "Age"], ylab = "partial residuals") 
plot(kyphosis$Start,  kyph.predict[,"Start"], ylab="") 
plot(kyphosis$Number, kyph.predict[,"Number"],ylab="")