Why not use panel.lmline?
MASS4 p.140 has the example
xyplot(Gas ~ Temp | Insul, whiteside, panel =
function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.lmline(x, y, ...)
}, xlab = "Average external temperature (deg. C)",
ylab = "Gas consumption (1000 cubic feet)", aspect = "xy",
strip = function(...) strip.default(..., style = 1))
and the definition of panel.lmline, namely
> panel.lmline
function(x, y, ...)
panel.abline(lm(y ~ x), ...)
suggests that the example you give should have worked.
On Tue, 21 Oct 2003, Dakin, Jonathan wrote:
> I'm trying to produce regression lines on each panel of a trellis using
> panel.abline.
>
> I can make it work when there is a single plot, by inserting:
>
> panel=function(x,y,...){panel.xyplot(x,y,...); panel.abline(lm(y~x))}
>
> into the script. Could anyone advise me on how to make it work for each
> panel of a multi-panel trellis ?
>
> I've tried replacing the regression object with:
> lmList(y~x | z, data=df )
>
> where z is the conditioning variable, but I can't work out how to pass the
> parameters into the panel function. Can anyone help ? Many thanks.
>
> (Splus 6 release 2)
>
> Jonathan Dakin
> Imperial College
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|