VGAM (version 1.1-11)

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


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


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



rootogram in countreg; an object of class "rootogram0"

inheriting from "data.frame" with about 8 variables.



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


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


numeric. Breaks for the histogram intervals.


maximum count displayed. If an error message occurs regarding running out of memory then use this argument; it might occur with a very long tailed distribution such as gaitdzeta.

xlab, main

graphical parameters.


numeric. Widths of the histogram bars.


any additional arguments to rootogram.default and plot.rootogram in countreg. Probably the most useful of these are style = c("hanging", "standing", "suspended") and scale = c("sqrt", "raw").


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


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.


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.


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. tools:::Rd_expr_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.


Run this code
if (FALSE) {
data("hspider", package = "VGAM")  # Count responses
hs.p   <- vglm(Pardlugu ~ CoveHerb,   poissonff, data = hspider)
hs.nb  <- vglm(Pardlugu ~ CoveHerb, negbinomial, data = hspider) <- 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(, max = 15, main = "zipoisson")
rootogram4(hs.zap, max = 15, main = "zapoisson")

Run the code above in your browser using DataLab