s-news
[Top] [All Lists]

Summary: Q re. panel.superpose with trellis

To: <s-news@lists.biostat.wustl.edu>
Subject: Summary: Q re. panel.superpose with trellis
From: "Dave Atkins" <datkins@u.washington.edu>
Date: Mon, 2 Apr 2001 10:58:36 -0700
Organization: University of Washington
Many thanks for the extremely helpful responses of Brian Ripley, Nick Ellis,
Renaud Lancelot, Madeline Bauer, Marcel Baumgartner, Pasi Korhonen, Rob
Balshaw, and David Smith.

My original question was how to fit separate loess smoothers to several
groups within a single panel using panel.superpose.  Nick Ellis provided the
solution using xyplot:

xyplot(outcome ~ time, data = df, groups = sex,
   panel = function(x, y, subscripts, groups) {
  panel.grid()
     panel.abline(60, 0, lty = 2)
  plot.line <- trellis.par.get("superpose.line")
       panel.superpose(x, y, subscripts, groups)
       panel.loess(x[groups[subscripts]=="Male"],
     y[groups[subscripts]=="Male"],
     span = 1, degree = 2,family = "gaussian",
     lty = plot.line$lty[1], col = plot.line$col[1])
      panel.loess(x[groups[subscripts]=="Female"],
     y[groups[subscripts]=="Female"],
     span = 1, degree = 2,family = "gaussian",
     lty = plot.line$lty[2], col = plot.line$col[2])
        },
 aspect = 3, xlab = "Time (in weeks)",
 ylab = "Outcome: Average GDS/DAS T-score")

Rob Balshaw noted that Harrell's xYplot can save quite a bit of typing.  An
almost identical plot can be created with:

library(Hmisc, T)
xYplot(outcome ~ time, data = sara.dis2, groups = sex, panel = panel.plsmo)
Key()

In addition, David Smith pointed out that there are a number of plotting
examples listed under example.xxxx.  For my problem, example.overplot proved
instructive.

Finally, other responses provided user-created code that also did the trick.
I won't insert those here, but if anyone is interested, I can pass along the
code (I am assuming that is okay with the original authors; I'll note who
it's from, of course.).

Thanks to everyone; you all saved me a lot of time and frustration.

cheers, dave

Dave Atkins
Center for Clinical Research
University of Washington
Email: datkins@u.washington.edu
Phone: 206.685.9383




<Prev in Thread] Current Thread [Next in Thread>
  • Summary: Q re. panel.superpose with trellis, Dave Atkins <=