Learn R Programming

mixAK (version 2.2)

cbplot: Plot a function together with its confidence/credible bands

Description

This routine typically plots a function together with its confidence or credible bands. The credible band can be indicated either by additional lines or by a shaded region or by both.

Usage

cbplot(x, y, low, upp, band.type=c("ls", "s", "l"), add=FALSE,
       col="darkblue", lty=1, lwd=2,
       cbcol=col, cblty=4, cblwd=lwd,
       scol=rainbow_hcl(1, start=180, end=180), slwd=5,
       xlim, ylim, xlab, ylab, main="", sub="", ...)

Arguments

x
a numeric vector with x coordinates corresponding to y, low, upp.
y
a numeric vector with y coordinates of the function to plot.
low
a numeric vector with y coordinates of the lower limit of the credible band.
upp
a numeric vector with y coordinates of the upper limit of the credible band.
band.type
a character which specifies the graphical way to show the credible band, ls stands for line and shaded region, s stands for shaded region only and l stands for line only.
add
if TRUE then everything is added to the current plot.
col, lty, lwd
graphical paramters to draw the x-y line.
cbcol, cblty, cblwd
graphical parameters to draw the x-low and x-upp lines.
scol, slwd
graphical parameters for the shaded region between the credible/confidence bounds.
xlim, ylim, xlab, ylab, main, sub
other graphical parameters.
...
additional arguments passed to the plot function.

Value

  • invisible(x)

Examples

Run this code
### Artificial credible bands around the CDF's of N(100, 15*15)
### and N(80, 10*10)
iq <- seq(55, 145, length=100)
Fiq <- pnorm(iq, 100, 15)
low <- Fiq - 0.1
upp <- Fiq + 0.1

iq2 <- seq(35, 125, length=100)
Fiq2 <- pnorm(iq, 80, 10)
low2 <- Fiq2 - 0.1
upp2 <- Fiq2 + 0.1

cbplot(iq, Fiq, low, upp, xlim=c(35, 145))
cbplot(iq2, Fiq2, low2, upp2, add=TRUE, col="red4",
       scol=rainbow_hcl(1, start=20, end=20))

Run the code above in your browser using DataLab