# [S] Trellis Question...

Timothy Johnson (tjohnson@s.psych.uiuc.edu)
Wed, 29 Apr 1998 18:27:29 -0500 (CDT)

Hi all. I'm having some trouble with trellis and would appreciate any
input you might have. I have a script that creates a xyplot trellis
display and includes fitted nonlinear regression line via a panel
function that I wrote. Here's my (sloppy) code:

my.panel <- function(x,y) {
param <- nls(y ~ exp(b0+b1*x)/(1+exp(b0+b1*x)),
start = c(b0 = 1, b1 = 1),
data = data.frame(x = x, y = y))\$parameters
x.temp <- seq(min(x), max(x), length=20)
y.temp <-
exp(param[1]+param[2]*x.temp)/(1+exp(param[1]+param[2]*x.temp))
lines(x.temp, y.temp)
legend(2,0.4,c(paste("b0 =",round(param[1],4)),
paste("b1 =",round(param[2],4))),cex=.5)
}

xyplot(cpdiff ~ groupsize | cats*tpar*sim, data = csim,
panel = function(x,y,...)
{panel.xyplot(x,y,cex=.60); my.panel(x,y)},
strip=function(...) strip.default(...,strip.name=c(T,T)))

What I would like to do is that instead of conditioning on three
factors, condition on only two and have it display the third by
plotting separate nonlinear regressions for each level of this
"collapsed" factor. I'm having difficulty seeing how I could do this.
I guess that maybe what I need is a more general version of
panel.superpose?