Panel function for confidence interval
panel.ci(x, y, lower, upper, groups = NULL, subscripts, col, fill = if (is.null(groups)) plot.line$col else superpose.line$col, alpha = 0.15, lty = 0, lwd = if (is.null(groups)) plot.line$lwd else superpose.line$lwd, grid = FALSE, ..., col.line = if (is.null(groups)) plot.line$col else superpose.line$col)
x | variables to be plotted in the scatterplot |
---|---|
y | variables to be plotted in the scatterplot |
lower | lower confidence limits |
upper | upper confidence limits |
groups | an optional grouping variable. If present,
|
subscripts | |
col | default colours are obtained from |
fill | other graphical parameters. |
alpha | opacity for the fill |
lty | other graphical parameters. |
lwd | other graphical parameters. |
grid | A logical flag, character string, or list specifying whether and how
a background grid should be drawn. This provides the same
functionality as Most generally,
No grid is drawn if |
... | Extra arguments, if any, for |
col.line | default colours are obtained from |
mod <- lm(Petal.Width ~ Petal.Length*Species, data = iris) newdat <- expand.grid(Petal.Length = seq(1, 7, by = 0.1), Species = c("setosa", "versicolor", "virginica")) pred <- predict(mod, newdat, interval = "confidence") dd <- cbind(newdat, pred) xyplot(fit ~ Petal.Length, groups = Species, data = dd, prepanel = prepanel.ci, auto.key = list(lines = TRUE, points = FALSE), ylab = "Petal Width", xlab = "Petal Length", lower = dd$lwr, upper = dd$upr, type = "l", panel = function(...) { panel.ci(..., alpha = 0.15, grid = TRUE) panel.xyplot(...) })