[R] Adding groups to regression line panel function in Lattice

Bigelow, Seth
2011-09-09T16:08:16Z

I wish to display a single-panel Lattice figure with grouped data and fitted
regression lines. I don't seem to be able to get the
individual regression lines to display, e.g.;

d <- data.frame(q = rep(1:6, each=10), cc = rep(seq(10,100, 10),6))
# create data frame with group identifier 'q', independent variable cc
d$ba = d$q*0.1*d$cc + 5*rnorm(nrow(d))
# create dependent variable 'ba'

mypanel <- function(...){
# panel function
                panel.lmline(d$cc, d$ba, groups = d$q)
#
                panel.xyplot(...)
                }

xyplot(ba~cc,d,
                groups=q,
                panel = panel.superpose,
                panel.groups=mypanel
                )

Can anyone suggest how to get lines to display by group? (and how to get lmline
panel to fit line without estimating an intercept?)


Seth W. Bigelow, Ph.D.
Research Ecologist
USDA-FS Pacific Southwest Research Station


	[[alternative HTML version deleted]]