quantileBands: Quantile bands

View source: R/quantileBands.R

quantileBandsR Documentation

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 reversely 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), recycled 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!

Note

This is the first version and is not tested very well yet.

Author(s)

Berry Boessenkool, berry-b@gmx.de, Sept 2014

See Also

quantile, quantileMean, ciBand, polygon, https://cran.r-project.org/package=fanplot

Examples


neff <- t(replicate(n=30, sapply(1:400, function(nn) max(rnorm(nn)))   ))
qB <- quantileBands(neff, x=1:400)
qB[,1:9]
quantileBands(neff, smooth=19, meanargs=list(col=2), txi=NA)

library(RColorBrewer)

quantileBands(neff, smooth=35, 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:\n it rises with sample size")

neff2 <- t(replicate(n=50, sapply(1:400, function(nn) mean(rnorm(nn)))   ))
quantileBands(neff2, x=1:400, smooth=35, 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")


berryFunctions documentation built on May 29, 2024, 4:01 a.m.