loess
by default, of
one variable (z
) against two others (x
and y
).
This panel function should be used with a levelplot
.panel.2dsmoother(x, y, z, subscripts = TRUE,
form = z ~ x * y, method = "loess", ...,
args = list(), n = 100)
form
. So in many cases you can skip these if
passing form
. In fact, for convenience, the formula
can be passed as the first argument method(form, data = list(x=x, y=y, z=z), {args})
.
See the Examples section for common choices.levelplot
.panel.levelplot
.method
).predict
method argument.loess
,
panel.smoother
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)
.featured_example <- TRUE
## 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) + s(y), method = "gam")
Run the code above in your browser using DataLab