47
47
A similar interpretation holds for \code{x} and \code{y} in
48
48
\code{prepanel.rootogram} and \code{panel.rootogram}.
50
Note that the data are assumed to arise from a discrete distribution
51
with some probability mass function. See details below.
51
54
\item{data}{ For the \code{"formula"} method, a data frame containing
83
This function implements Tukey's hanging rootograms. Also consider
84
the \code{rootogram} function in the \code{vcd} package, especially if
85
the number of unique values is small. }
87
This function implements Tukey's hanging rootograms. As implemented,
88
\code{rootogram} assumes that the data arise from a discrete
89
distribution (either supplied in raw form, when \code{y} is
90
unspecified, or in terms of the frequency distribution) with some
91
unknown probability mass function (p.m.f.). The purpose of the plot
92
is to check whether the supplied theoretical p.m.f. \code{dfun} is a
93
reasonable fit for the data.
95
It is reasonable to consider rootograms for continuous data by
96
discretizing it (similar to a histogram), but this must be done by the
97
user before calling \code{rootogram}. An example is given below.
99
Also consider the \code{rootogram} function in the \code{vcd} package,
100
especially if the number of unique values is small.
88
\code{rootogram} produces an object of class \code{"trellis"}. The
106
\code{rootogram} produces an object of class \code{"trellis"}. The
89
107
\code{update} method can be used to update components of the object and
90
108
the \code{print} method (usually called by default) will plot it on an
91
109
appropriate plotting device.
115
John W. Tukey (1972) Some graphic and semi-graphic displays. In
116
T. A. Bancroft (Ed) \emph{Statistical Papers in Honor of George
117
W. Snedecor}, pp. 293--316. Available online at
118
\url{http://www.edwardtufte.com/tufte/tukey}
94
122
\author{ Deepayan Sarkar \email{deepayan.sarkar@gmail.com}}
96
124
\code{\link{xyplot}}
146
174
sub = "Random sample from Poisson(50)")
177
## Example using continuous data
181
## 'discretize' by binning and replacing data by bin midpoints
183
h <- hist(xnorm, plot = FALSE)
185
## Option 1: Assume bin probabilities proportional to dnorm()
187
norm.factor <- sum(dnorm(h$mids, mean(xnorm), sd(xnorm)))
189
rootogram(counts ~ mids, data = h,
191
dnorm(x, mean(xnorm), sd(xnorm)) / norm.factor
194
## Option 2: Compute probabilities explicitly using pnorm()
196
pdisc <- diff(pnorm(h$breaks, mean = mean(xnorm), sd = sd(xnorm)))
197
pdisc <- pdisc / sum(pdisc)
199
rootogram(counts ~ mids, data = h,
201
f <- factor(x, levels = h$mids)