Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rootogram4vglm

Rootograms (S4 generic) for Assessing Goodness of Fit of Probability Models


Description

A graphical technique for comparing the observed and fitted counts from a probability model, on a square root scale.

Usage

rootogram4(object, ...)
rootogram4vglm(object, newdata = NULL, breaks = NULL, max = NULL,
               xlab = NULL, main = NULL, width = NULL, ...)

Arguments

object

an object of class "vglm". zz This includes "vgam" because "vlm" handles both VGLM and VGAM objects.

newdata

Data upon which to base the calculations. The default is the one used to fit the model.

breaks

numeric. Breaks for the histogram intervals.

max

maximum count displayed.

xlab, main

graphical parameters.

width

numeric. Widths of the histogram bars.

...

any additional arguments to rootogram.default and plot.rootogram in countreg.

Details

Rootograms are a useful graphical technique for comparing the observed counts with the expected counts given a probability model.

This S4 implementation is based very heavily on rootogram coming from countreg. This package is primarily written by A. Zeileis and C. Kleiber. That package is currently on R-Forge but not CRAN, and it is based on S3. Since VGAM is written using S4, it was necessary to define an S4 generic function called rootogram4() which dispatches appropriately for S4 objects.

Currently, only a selected number of VGAM family functions are implemented. Over time, hopefully more and more will be completed.

Value

See rootogram in countreg; an object of class "rootogram0" inheriting from "data.frame" with about 8 variables.

Warning

This function is rudimentary and based totally on the implementation in countreg.

Note

The function names used coming from countreg have been renamed slightly to avoid conflict.

Author(s)

Package countreg is primarily written by A. Zeileis and C. Kleiber. Function rootogram4() is based very heavily on countreg. T. W. Yee wrote code to unpack variables from many various models and feed them into the appropriate d-type function.

References

Friendly, M. and Meyer, D. (2016). Discrete Data Analysis with R: Visualization and Modeling Techniques for Categorical and Count Data, Boca Raton, FL, USA: Chapman & Hall/CRC Press.

Kleiber, C. and Zeileis, A. (2016) “Visualizing Count Data Regressions Using Rootograms.” The American Statistician, 70(3), 296–303. doi: 10.1080/00031305.2016.1173590.

Tukey, J. W. (1977) Exploratory Data Analysis, Reading, MA, USA: Addison-Wesley.

See Also

vglm, vgam, glm, zipoisson, zapoisson, rootogram in countreg.

Examples

## Not run: 
data("hspider", package = "VGAM")  # Count responses
hs.p   <- vglm(Pardlugu ~ CoveHerb,   poissonff, data = hspider)
hs.nb  <- vglm(Pardlugu ~ CoveHerb, negbinomial, data = hspider)
hs.zip <- vglm(Pardlugu ~ CoveHerb,   zipoisson, data = hspider)
hs.zap <- vglm(Pardlugu ~ CoveHerb,   zapoisson, data = hspider)

opar <- par(mfrow = c(2, 2))  # Plot the rootograms
rootogram4(hs.p,   max = 15, main = "poissonff")
rootogram4(hs.nb,  max = 15, main = "negbinomial")
rootogram4(hs.zip, max = 15, main = "zipoisson")
rootogram4(hs.zap, max = 15, main = "zapoisson")
par(opar)

## End(Not run)

VGAM

Vector Generalized Linear and Additive Models

v1.1-5
GPL-3
Authors
Thomas Yee [aut, cre], Cleve Moler [ctb] (author of several LINPACK routines)
Initial release
2021-01-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.