DrawBand {DescTools} | R Documentation |
Draw Confidence Band
Description
Draw a band using a simple syntax. Just a wrapper for the function polygon()
typically used to draw confidence bands.
Usage
DrawBand(x, y, col = SetAlpha("grey", 0.5), border = NA)
Arguments
x |
a vector or a matrix with x coordinates for the band. If x is given as matrix it must be a |
y |
a vector or a matrix with y coordinates for the band. If y is given as matrix it must be a |
col |
the color of the band. |
border |
the border color of the band. |
Author(s)
Andri Signorell <andri@signorell.net>
See Also
Examples
set.seed(18)
x <- rnorm(15)
y <- x + rnorm(15)
new <- seq(-3, 3, 0.5)
pred.w.plim <- predict(lm(y ~ x), newdata=data.frame(x=new), interval="prediction")
pred.w.clim <- predict(lm(y ~ x), newdata=data.frame(x=new), interval="confidence")
plot(y ~ x)
DrawBand(y = c(pred.w.plim[,2], rev(pred.w.plim[,3])),
x=c(new, rev(new)), col= SetAlpha("grey90", 0.5))
# passing y as matrix interface allows more intuitive arguments
DrawBand(y = pred.w.clim[, 2:3],
x = new, col= SetAlpha("grey80", 0.5))
abline(lm(y~x), col="brown")
[Package DescTools version 0.99.55 Index]