s-news
[Top] [All Lists]

Re: abline for multiple trellis panels

To: "Dakin, Jonathan" <j.dakin@imperial.ac.uk>
Subject: Re: abline for multiple trellis panels
From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
Date: Tue, 21 Oct 2003 13:07:25 +0100 (BST)
Cc: "'s-news@lists.biostat.wustl.edu'" <s-news@lists.biostat.wustl.edu>
In-reply-to: <9A760AEE164ED71190D00002A542BB6301866077@icex2.cc.ic.ac.uk>
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


<Prev in Thread] Current Thread [Next in Thread>