I am trying to do some comparisons of density estimators using lattice. The code below attempts to plot the same histogram in each panel and then overplots a kernel estimate with different bandwidths. Finding packet.number() was a bit arduous, but seems to do what I want. My concern now is that close examination of the 4 histograms reveals that they are different even though they use the same data, and use the same binning. Can someone explain this, or better yet suggest a fix? Admittedly, the kernel estimates are rather silly, they are just standing in for something else that I would like to think is less silly.
Many thanks, Roger require(REBayes) # Source for the velo data require(lattice) x <- velo x <- x[!(x == 0)] bandwidths <- (1:4)*10 lp <- histogram(~x|bw, nint = 100, border = grey(.9), col = grey(.9), type = "density", panel = function(x, bw = bandwidths, ...){ panel.histogram(x, ...) f <- density(x, bw[packet.number()]) panel.lines(f$x, f$y, col = "blue", lwd = 1.5) }) print(lp) url: www.econ.uiuc.edu/~roger Roger Koenker email rkoen...@uiuc.edu Department of Economics vox: 217-333-4558 University of Illinois fax: 217-244-6678 Urbana, IL 61801 ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.