rootogram {vcd} | R Documentation

## Rootograms

### Description

Rootograms of observed and fitted values.

### Usage

    ## Default S3 method:
    rootogram(x, fitted, names = NULL, scale = c("sqrt", "raw"),
      type = c("hanging", "standing", "deviation"),
      rect_gp = gpar(fill = "lightgray"), lines_gp = gpar(col = "red"),
      points_gp = gpar(col = "red"), pch = 19,
      xlab = NULL, ylab = NULL, ylim = NULL,
      name = "rootogram", newpage = TRUE, pop = TRUE, ...)

### 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 `grid_barplot`, if set to `NULL` the names of `x` are used.
`scale` | a character string indicating whether 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.
`rect_gp` | a `"gpar"` object controlling the grid graphical parameters of the rectangles.
`lines_gp` | a `"gpar"` object controlling the grid graphical parameters of the lines.
`points_gp` | a `"gpar"` object controlling the grid graphical parameters of the points.
`pch` | plotting character for the points.
`xlab` | a label for the x axis.
`ylab` | a label for the y axis.
`ylim` | limits for the y axis.
`name` | name of the plotting viewport.
`newpage` | logical. Should `grid.newpage` be called before plotting?
`pop` | logical. Should the viewport created be popped?
`...` | further arguments passed to `grid_barplot`.

### Details

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

### Author(s)

Achim Zeileis Achim.Zeileis@R-project.org

### References

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

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

### See Also

`grid_barplot`

### 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 vcd version 0.9-6 Index]