residuals.zeroinflation: Residuals in Regression Models to deal with Zero-Excess in...

View source: R/overglm3.R

residuals.zeroinflationR Documentation

Residuals in Regression Models to deal with Zero-Excess in Count Data

Description

Computes various types of residuals to assess the individual quality of model fit in regression models to deal with zero-excess in count data.

Usage

## S3 method for class 'zeroinflation'
residuals(
  object,
  type = c("quantile", "standardized", "response"),
  plot.it = FALSE,
  identify,
  ...
)

Arguments

object

an object of class zeroinflation.

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"); (3) the randomized quantile residual ("quantile"). By default, type is set to "quantile".

plot.it

an (optional) logical switch indicating if the plot of residuals versus the fitted values is required. As default, plot.it is set to FALSE.

identify

an (optional) positive integer value indicating the number of individuals to identify on the plot of residuals versus the fitted values. 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.

Value

A vector with the observed residuals type type.

References

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

Examples

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

####### Example 2: Article production by graduate students in biochemistry PhD programs
bioChemists <- pscl::bioChemists
fit2 <- zeroinf(art ~ fem + kid5 + ment | ment, family="nb1(log)", data = bioChemists)
residuals(fit2, type="quantile", plot.it=TRUE, 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.