Description Usage Arguments Details Author(s) See Also Examples
View source: R/panel.2dsmoother.R
Plot a smooth approximation, using loess
by default, of
one variable (z
) against two others (x
and y
).
This panel function should be used with a levelplot
.
1 2 3  panel.2dsmoother(x, y, z, subscripts = TRUE,
form = z ~ x * y, method = "loess", ...,
args = list(), n = 100)

x, y, z 
data points. If these are missing, they will be looked for in the
environment of 
form, method 
the smoothing model is constructed (approximately) as

subscripts 
data indices for the current packet, as passed in by 
... 
further arguments passed on to 
args 
a list of further arguments to the model function ( 
n 
number of equispaced points along each of x and y on which to evaluate the smooth function. 
This should work with any model function that takes a formula
argument, and has a predict
method argument.
Felix Andrews felix@nfrac.org
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  set.seed(1)
xyz < data.frame(x = rnorm(100), y = rnorm(100))
xyz$z < with(xyz, x * y + rnorm(100, sd = 1))
levelplot(z ~ x * y, xyz, panel = panel.2dsmoother)
## showing data points on the same color scale
levelplot(z ~ x * y, xyz,
panel = panel.levelplot.points, cex = 1.2) +
layer_(panel.2dsmoother(..., n = 200))
## simple linear regression model
levelplot(z ~ x * y, xyz,
panel = panel.levelplot.points) +
layer_(panel.2dsmoother(..., method = "lm"))
## GAM smoother with smoothness by cross validation
if (require("mgcv"))
levelplot(z ~ x * y, xyz, panel = panel.2dsmoother,
form = z ~ s(x, y), method = "gam")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.