/ Home
S-Archive Download Script
qres   Randomized quantile residuals
DESCRIPTION
Computes randomized quantile residuals for binomial, Poisson, negative binomial, gamma and inverse Gaussian generalized linear models.
 
USAGE
qres.binom(glm.obj)
qres.pois(glm.obj)
qres.nbinom(glm.obj)
qres.gamma(glm.obj,dispersion=NULL)
qres.invgauss(glm.obj,dispersion=NULL)
qres.tweedie(glm.obj,dispersion=NULL)
 
REQUIRED ARGUMENT
glm.obj   Object of class "glm". The generalized linear model family is assumed to be "binomial" for qres.binom, "poisson" for qres.pois, "negative binomial" for qres.nbinom, "Gamma" for qres.gamma, "inverse Gaussian" for qres.invgauss or "tweedie" for qres.tweedie.
 
OPTIONAL ARGUMENT
dispersion   a positive real number. Specifies the value of the dispersion parameter for a Gamma or inverse Gaussian generalized linear model if known. If NULL, the dispersion will be estimated by its Pearson estimator (gamma) or by restricted maximum likelihood (inverse Gaussian).
 
VALUE
Numeric vector of standard normal quantile residuals.
 
BACKGROUND
Quantile residuals are based on the idea of inverting the estimated distribution function for each observation to obtain exactly standard normal residuals. In the case of discrete distributions, such as the binomial and Poisson, some randomization is introduced to produce continuous normal residuals. Quantile residuals are the residuals of choice for generalized linear models in large dispersion situations when the deviance and Pearson residuals can be grossly non-normal. Quantile residuals are the only useful residuals for binomial or Poisson data when the response takes on only a small number of distinct values.
 
REFERENCE
Dunn, K. P., and Smyth, G. K. (1996). Randomized quantile residuals. J. Comput. Graph. Statist., 5, 1-10.
 
SEE ALSO
Inverse Gaussian Distribution, Tweedie Distributions, tweedie family
 
EXAMPLES
This is a binary regression (binomial) example. Compare the data analysis of the kyphosis data set in the S-Plus manual entry on logistic regression.
> kyph.glm <- glm(Kyphosis ~ Age+Number+Start, family=binomial, data=kyphosis)
> r <- qres.binom(kyph.glm)
> plot(fitted(kyph.glm),r)
The plot of residuals against fitted values shows reasonable random scatter.
> plot(kyphosis$Age,r)
> plot(kyphosis$Number,r)
> plot(kyphosis$Start,r)

# Gamma example with chisquare responses on 1 df
glm.obj <- glm(y~x,family=Gamma(link="log"))
qr <- qres.gamma(glm.obj,dispersion=2)
qqnorm(qr)
abline(0,1)

 

S-Archive Download Script

Gordon Smyth. Copyright © 1996-2016. Last modified: 10 February 2004