envelope.overglm: Normal QQ-plot with Simulated Envelope of Residuals for...

View source: R/overglm3.R

envelope.overglmR Documentation

Normal QQ-plot with Simulated Envelope of Residuals for alternatives to the Poisson and Binomial Regression Models under the presence of Overdispersion

Description

Produces a normal QQ-plot with simulated envelope of residuals for regression models based on the negative binomial, beta-binomial, and random-clumped binomial distributions, which are alternatives to the Poisson and binomial regression models under the presence of overdispersion.

Usage

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

Arguments

object

an object of class overglm.

rep

an (optional) positive integer which allows to specify the number of replicates which should be used to build the simulated envelope. By default, rep is set to be 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 conform the simulated envelope. By default, conf is set to be 0.95.

type

an (optional) character string which allows to specify the required type of residuals. The available options are: (1) the difference between the observed response and the fitted mean ("response"); (2) the standardized difference between the observed response and the fitted mean ("standardized"); and (3) the randomized quantile residual ("quantile"). By default, type is set to be "quantile".

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. By default, plot.it is set to be TRUE.

identify

an (optional) positive integer value 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

The simulated envelope is builded by simulating rep independent realizations of the response variable for each individual, which is accomplished taking into account the following: (1) the model assumption about the distribution of the response variable; (2) the estimates of the parameters in the linear predictor; and (3) the estimate of the dispersion parameter. The interest model is re-fitted rep times, as each time the vector of observed responses is replaced by one of the simulated samples. The type-type residuals are computed and then sorted for each replicate, so that for each i=1,2,...,n, where n is the number of individuals in the sample, there is a random sample of size rep of the i-th order statistic of the type-type residuals. Therefore, the simulated envelope is composed 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.

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

See Also

envelope.lm, envelope.glm, envelope.zeroinflation

Examples

###### Example 1: Self diagnozed ear infections in swimmers
data(swimmers)
fit1 <- overglm(infections ~ frequency + location, family="nb1(log)", data=swimmers)
envelope(fit1, rep=30, conf=0.95, type="quantile", col="red", pch=20, col.lab="blue",
         col.axis="blue", col.main="black", family="mono", cex=0.8, plot.it=TRUE)

###### Example 2: Article production by graduate students in biochemistry PhD programs
bioChemists <- pscl::bioChemists
fit2 <- overglm(art ~ fem + kid5 + ment, family="nb1(log)", data = bioChemists)
envelope(fit2, rep=30, conf=0.95, type="quantile", col="red", pch=20, col.lab="blue",
         col.axis="blue", col.main="black", family="mono", cex=0.8, plot.it=TRUE)

###### Example 3: Agents to stimulate cellular differentiation
data(cellular)
fit3 <- overglm(cbind(cells,200-cells) ~ tnf + ifn, family="bb(logit)", data=cellular)
envelope(fit3, rep=30, conf=0.95, type="quantile", col="red", pch=20, col.lab="blue",
         col.axis="blue", col.main="black", family="mono", cex=0.8, plot.it=TRUE)


glmtoolbox documentation built on Oct. 10, 2023, 9:06 a.m.