rootogram {vcd}R Documentation

Rootograms

Description

Rootograms of observed and fitted values.

Usage

rootogram(x, fitted, names = NULL, scale = c("sqrt", "raw"),
                            type = c("hanging", "standing", "deviation"),
                            bar.col = grey(0.7), line.col = 2,
                            xlab = NULL, ylab = NULL, ylim = NULL, ...)

Arguments

x either a vector or a 1-way table of frequencies.
fitted a vector of fitted frequencies.
names a vector of names passed to barplot, if set to NULL the names of x are used.
scale a character string indicating wether the values should be plotted on the raw or square root scale.
type a character string indicating if the bars for the observed frequencies should be hanging or standing or indicate the deviation between observed and fitted frequencies.
bar.col bar color (observed frequencies).
line.col line color (fitted frequencies).
xlab a label for the x axis.
ylab a label for the y axis.
ylim limits for the y axis.
... further arguments passed to barplot.

Details

The observed frequencies are displayed as bars and the fitted frequencies as a line. By default a log scale is used to make the smaller frequencies more visible.

Author(s)

Achim Zeileis

References

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

M. Friendly (2000), Visualizing Categorical Data. SAS Institute, Cary, NC.

Examples

## Simulated data examples:
dummy <- rnbinom(200, size = 1.5, prob = 0.8)
observed <- table(dummy)
fitted1 <- dnbinom(as.numeric(names(observed)), size = 1.5, prob = 0.8) * sum(observed)
fitted2 <- dnbinom(as.numeric(names(observed)), size = 2, prob = 0.6) * sum(observed)
rootogram(observed, fitted1)
rootogram(observed, fitted2)

## Real data examples:
data(HorseKicks)
HK.fit <- goodfit(HorseKicks)
summary(HK.fit)
plot(HK.fit)
## or equivalently
rootogram(HK.fit)

data(Federalist)
F.fit <- goodfit(Federalist, type = "nbinomial")
summary(F.fit)
plot(F.fit)

[Package Contents]