rootogram for normal distributions
Thank you very much for your qualified answers, and also for the link to the Tukey paper. I appreciate Tukey's writings very much. Looking at the lattice code (below), a possible implementation might involve binning, not so? I see a problematic part here: xx <- sort(unique(x)) Unique certainly works well with Poisson distributed data, but is essentially a no-op when confronted with continous floating-point numbers. Best Hugo
prepanel.rootogram
function (x, y = table(x), dfun = NULL, transformation = sqrt,
hang = TRUE, ...)
{
plot.line <- trellis.par.get("plot.line")
stopifnot(is.function(dfun))
yy <- transformation(y/sum(y))
xx <- sort(unique(x))
dotArgs <- list(...)
dfunArgs <- names(formals(dfun))
if (!("..." %in% dfunArgs))
dotArgs <- dotArgs[dfunArgs[-1]]
dd <- transformation(do.call(dfun, c(list(xx), dotArgs)))
list(xlim = range(xx), ylim = if (hang) range(dd, dd - yy,
0) else range(dd, yy, 0), dx = diff(xx), dy = diff(dd))
}
panel.rootogram
function (x, y = table(x), dfun = NULL, col = plot.line$col,
lty = plot.line$lty, lwd = plot.line$lwd, alpha = plot.line$alpha,
transformation = sqrt, hang = TRUE, ...)
{
plot.line <- trellis.par.get("plot.line")
ref.line <- trellis.par.get("reference.line")
stopifnot(is.function(dfun))
yy <- transformation(y/sum(y))
xx <- sort(unique(x))
dotArgs <- list(...)
dfunArgs <- names(formals(dfun))
if (!("..." %in% dfunArgs))
dotArgs <- dotArgs[dfunArgs[-1]]
dd <- transformation(do.call(dfun, c(list(xx), dotArgs)))
panel.abline(h = 0, col = ref.line$col, lty = ref.line$lty,
lwd = ref.line$lwd, alpha = ref.line$alpha)
panel.segments(xx, if (hang)
dd
else 0, xx, if (hang)
(dd - yy)
else yy, col = col, lty = lty, lwd = lwd, alpha = alpha,
...)
panel.lines(xx, dd)
}
<environment: namespace:latticeExtra>
On Sunday 16 January 2011 15:59:58 Achim Zeileis wrote:
On Sun, 16 Jan 2011, Hadley Wickham wrote:
The normal distribution is a continuous distribution, i.e., the frequency for each observed value will essentially be 1/n and not converge to the density function. Hence, you would need to look at histogram or smoothed densities. Rootograms, on the other hand, are intended for discrete distributions.
I don't think that's true - rootograms are useful for both continuous and discrete distributions. See (e.g.) p 314 at http://www.edwardtufte.com/tufte/tukey, where Tukey himself uses a rootogram with a normal distribution.
OK, let me rephrase: Rootograms as implemented in rootogram() are intended for discrete distributions. At least that's my reading. But maybe I've missed a trick that you can point us to. Z
Hadley
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.