[R] How do I add fitted curves to coplots?

Prof Brian D Ripley ripley at stats.ox.ac.uk
Wed May 17 08:49:29 CEST 2000


On Tue, 16 May 2000, John S. Walker wrote:

> I've been performing an analysis of some data by a follow the leader
> method (Bad I know but it seems to work and I think I understand all the
> steps now) and I've run into a problem. The analysis is for all practical
> purposes identical to the non-linear mixed effects analysis performed on
> Ludbrooks Rabbit data in the second edition of Venables & Ripley (page
> 315--321). I have the stats pretty much done and have estimates for all
> the model parameters from the nlme object.  Now I want to add the fitted
> lines to my coplot of the data in the manner of figure 10.3.  How would I
> do this? I owuld guess that I use the lines function or the panel function
> but I can't find an index varibale to tell me what panel I'm in. Any
> suggestions?

You need to fake it. There is an example in the 3rd edition R scripts,
which for the Rabbit data becomes

coplot(seq(0,40, len=60) ~ log(Dose) | Animal * Treatment, Rabbit,
       show.given=FALSE,
       panel = function(x, y, ...) {
           ind <- round(1 + 59*y/40)
           lines(spline(x, fitted(R.nlme2)[ind]))
           points(x, Rabbit$BPchange[ind])
       })

coplot does not have the subscripts = T argument that Trellis has.
I think we could usefully add it (since `lattice' seems nowhere visible
yet), and I will do so for 1.1.0.  Also, the handling of xlab/ylab differs
a bit from the S original, and I will take a look.

-- 
Brian D. Ripley,                  ripley at 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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list