Learn R Programming

berryFunctions (version 1.7.1)

quantileBands: quantile bands

Description

Quantile bands with optional smoothing, e.g. for visualizing simulations

Usage

quantileBands(mat, x=1:ncol(mat), col=rgb(0,0,1, alpha=c(0.5, 0.7)),
add=FALSE, main="Quantile Bands", ylab="", xlab="", probs=0:4/4, na.rm=FALSE,
type=7, smooth=NA, medargs=NULL, meanargs=NULL, txi, textargs=NULL, ...)

Arguments

mat
Matrix or data.frame with columns of data
x
X-axis positions for each column. DEFAULT: 1:ncol(mat)
col
Vector of colors for each quantile group, recycled reversively if necessary. DEFAULT: rgb(0,0,1, alpha=c(0.5, 0.7))
add
Add to existing plot? Allows to add to highly customized plot. DEFAULT: FALSE
main, xlab, ylab
plot labels. DEFAULT: "Quantile Bands", ""
probs
Probabilities passed to quantile. DEFAULT: 0:4/4
na.rm
Remove NAs before computing quantiles, median and mean? DEFAULT: FALSE
type
Which of the 9 quantile algorithms should be used. DEFAULT: 7
smooth
If(!is.na), width passed to movAv smoothing quantiles. DEFAULT: NA
medargs
List of arguments passed to lines drawing median. Not drawn if NULL. DEFAULT: NULL
meanargs
List of arguments passed to lines drawing mean. Not drawn if NULL. DEFAULT: NULL
txi
Text x position index (along columns of mat), recyled if necessary. NA to suppress. INTERNAL DEFAULT: middle of the plot for all.
textargs
List of arguments passed to text, like col, adj, ... DEFAULT: NULL
...
Further arguments passed to polygon, like border, lty, ...

Value

  • Quantiles of each column, invisible. Smoothed if smooth is given!

See Also

quantile, quantileMean, polygon

Examples

Run this code
neff <- t(sapply(1:30, function(i) sapply(1:100*10, function(n) max(rnorm(n)))))
qB <- quantileBands(neff, x=1:100*10)
qB[,1:10]
quantileBands(neff, x=1:100*10, smooth=19, meanargs=list(col=2), txi=NA)

library(RColorBrewer)

quantileBands(neff, x=1:100*10, smooth=9, ylab="max of rnorm(n)",
  xlab="sample size (n)", probs=0:10/10, col=brewer.pal(5,"BuGn"),
  medargs=list(lwd=2), meanargs=list(col=2, lty=1), txi=c(40,50,60),
  main="Maximum is an unsaturated statistic:
 it rises with sample size")

neff2 <- t(sapply(1:30, function(i) sapply(1:100*10, function(n) mean(rnorm(n)))))
quantileBands(neff2, x=1:100*10, smooth=9, ylab="mean of rnorm(n)",
  xlab="sample size (n)", probs=0:10/10, col=brewer.pal(5,"BuGn"),
  txi=c(40,50,60), textargs=list(col="yellow"), medargs=list(lwd=2),
  meanargs=list(col=2, lty=1), main="Mean converges to true population mean")

Run the code above in your browser using DataLab