Skip to content

Adding groups to regression line panel function in Lattice

2 messages · Bigelow, Seth, Deepayan Sarkar

2 days later
#
On Fri, Sep 9, 2011 at 9:38 PM, Bigelow, Seth <sbigelow at fs.fed.us> wrote:
But panel.lmline() does not honour a 'groups' argument, so there is no
reason for this to work.
How about

xyplot(ba~cc,d, groups=q, type=c("p", "r"))
xyplot(ba~cc,d, groups=q, panel = panel.superpose,
       panel.groups = function(x, y, ...) {
           panel.xyplot(x, y, ...)
           panel.abline(0, coef(lm(y ~ 0 + x)), ...)
       })

-Deepayan