envelope.gnm: Normal QQ-plot with simulated envelope of residuals in...

View source: R/data.R

envelope.gnmR Documentation

Normal QQ-plot with simulated envelope of residuals in Generalized Nonlinear Models

Description

Produces a normal QQ-plot with simulated envelope of residuals for generalized nonlinear models.

Usage

## S3 method for class 'gnm'
envelope(
  object,
  rep = 25,
  conf = 0.95,
  type = c("quantile", "deviance", "pearson"),
  standardized = FALSE,
  plot.it = TRUE,
  identify,
  ...
)

Arguments

object

an object of the class gnm.

rep

an (optional) positive integer which allows to specify the number of replicates which should be used to build the simulated envelope. As default, rep is set to 25.

conf

an (optional) value in the interval (0,1) indicating the confidence level which should be used to build the pointwise confidence intervals, which form the envelope. As default, conf is set to 0.95.

type

a character string indicating the type of residuals which should be used. The available options are: randomized quantile ("quantile"), deviance ("deviance") and pearson ("pearson") residuals. As default, type is set to "quantile".

standardized

an (optional) logical switch indicating if the residuals should be standardized by dividing by the square root of (1-h), where h is a measure of leverage. As default, standardized is set to FALSE.

plot.it

an (optional) logical switch indicating if the normal QQ-plot with simulated envelope of residuals is required or just the data matrix in which it is based. As default, plot.it is set to TRUE.

identify

an (optional) positive integer indicating the number of individuals to identify on the QQ-plot with simulated envelope of residuals. This is only appropriate if plot.it=TRUE.

...

further arguments passed to or from other methods. If plot.it=TRUE then ... may be used to include graphical parameters to customize the plot. For example, col, pch, cex, main, sub, xlab, ylab.

Details

In order to construct the simulated envelope, rep independent realizations of the response variable for each individual are simulated, which is done by considering (1) the model assumption about the distribution of the response variable; (2) the estimation of the "linear" predictor parameters; and (3) the estimation of the dispersion parameter. Each time, the vector of observed responses is replaced with one of the simulated samples, re-fitting the interest model rep times. For each i=1,2,...,n, where n is the number of individuals in the sample, the i-th order statistic of the type-type residuals is computed and then sorted for each replicate, giving a random sample of size rep of the i-th order statistic. In other words, the simulated envelope is comprised of the quantiles (1 - conf)/2 and (1 + conf)/2 of the random sample of size rep of the i-th order statistic of the type-type residuals for i=1,2,...,n.

Value

A matrix with the following four columns:

Lower limit the quantile (1 - conf)/2 of the random sample of size rep of the i-th order
statistic of the type-type residuals for i=1,2,...,n,
Median the quantile 0.5 of the random sample of size rep of the i-th order
statistic of the type-type residuals for i=1,2,...,n,
Upper limit the quantile (1 + conf)/2 of the random sample of size rep of the i-th order
statistic of the type-type residuals for i=1,2,...,n,
Residuals the observed type-type residuals,

References

Atkinson A.C. (1985) Plots, Transformations and Regression. Oxford University Press, Oxford.

Davison A.C., Gigli A. (1989) Deviance Residuals and Normal Scores Plots. Biometrika 76, 211-221.

Dunn P.K., Smyth G.K. (1996) Randomized Quantile Residuals. Journal of Computational and Graphical Statistics 5, 236-244.

Pierce D.A., Schafer D.W. (1986) Residuals in Generalized Linear Models. Journal of the American Statistical Association 81, 977-986.

Wei B.C. (1998). Exponential Family Nonlinear Models. Springer, Singapore.

See Also

envelope.lm, envelope.overglm

Examples

###### Example 1: The effects of fertilizers on coastal Bermuda grass
data(Grass)
fit1 <- gnm(Yield ~ b0 + b1/(Nitrogen + a1) + b2/(Phosphorus + a2) + b3/(Potassium + a3),
            family=gaussian(inverse), start=c(b0=0.1,b1=13,b2=1,b3=1,a1=45,a2=15,a3=30), data=Grass)

#envelope(fit1, rep=50, conf=0.95, type="quantile", col="red", pch=20, col.lab="blue",
#         col.axis="blue", col.main="black", family="mono", cex=0.8)

###### Example 2: Assay of an Insecticide with a Synergist
data(Melanopus)
fit2 <- gnm(Killed/Exposed ~ b0 + b1*log(Insecticide-a1) + b2*Synergist/(a2 + Synergist),
            family=binomial(logit), weights=Exposed, start=c(b0=-3,b1=1.2,a1=1.7,b2=1.7,a2=2),
		   data=Melanopus)

#envelope(fit2, rep=50, conf=0.95, type="pearson", col="red", pch=20, col.lab="blue",
#         col.axis="blue", col.main="black", family="mono", cex=0.8)

###### Example 3: Developmental rate of Drosophila melanogaster
data(Drosophila)
fit3 <- gnm(Duration ~ b0 + b1*Temp + b2/(Temp-a), family=Gamma(log),
            start=c(b0=3,b1=-0.25,b2=-210,a=55), weights=Size, data=Drosophila)

#envelope(fit3, rep=50, conf=0.95, type="quantile", col="red", pch=20, col.lab="blue",
#         col.axis="blue", col.main="black", family="mono", cex=0.8)

###### Example 4: Radioimmunological Assay of Cortisol
data(Cortisol)
fit4 <- gnm(Y ~ b0 + (b1-b0)/(1 + exp(b2+ b3*lDose))^b4, family=Gamma(identity),
            start=c(b0=130,b1=2800,b2=3,b3=3,b4=0.5), data=Cortisol)

#envelope(fit4, rep=50, conf=0.95, type="quantile", col="red", pch=20, col.lab="blue",
#         col.axis="blue", col.main="black", family="mono", cex=0.8)


glmtoolbox documentation built on Sept. 11, 2024, 7:32 p.m.