Learn R Programming

miscFuncs (version 1.5-9)

qqci: qqci function

Description

A function to compare quantiles of a given vector against quantiles of a specified distribution. The function outputs simulation-based confidence intervals too. The option of zero-ing the plot (rather than visualising a diagonal line (which can be difficult to interpret) and also standardising (so that varying uncertainty around each quantile appears equal to the eye) are also given.

Usage

qqci(
  x,
  rfun = NULL,
  y = NULL,
  ns = 100,
  zero = FALSE,
  standardise = FALSE,
  qts = c(0.025, 0.975),
  llwd = 2,
  lcol = "red",
  xlab = "Theoretical",
  ylab = "Sample",
  alpha = 0.02,
  cicol = "black",
  cilwd = 1,
  ...
)

Value

Produces a QQ-plot with simulation-based confidence bands

Arguments

x

a vector of values to compare

rfun

a function accepting a single argument to generate samples from the comparison distribution, the default is rnorm

y

an optional vector of samples to compare the quantiles against. In the case this is non-null, the function rfun will be automatically chosen as bootstrapping y with replacement and sample size the same as the length of x. You must specify exactly one of rfun or y.

ns

the number of simulations to generate: the more simulations, the more accurate the confidence bands. Default is 100

zero

logical, whether to zero the plot across the x-axis. Default is FALSE

standardise

logical, whether to standardise so that the variance around each quantile is made constant (this can help in situations where the confidence bands appear very tight in places)

qts

vector of probabilities giving which sample-based empirical quantiles to add to the plot. Default is c(0.025,0.975)

llwd

positive numeric, the width of line to plot, default is 2

lcol

colour of line to plot, default is red

xlab

character, the label for the x-axis

ylab

character, the label for the y-axis

alpha

controls transparency of samples (coloured blue)

cicol

colour of confidence band lines, default is black

cilwd

width of confidence band lines, default is 1

...

additional arguments to pass to matplot

Examples

Run this code
qqci(rnorm(1000))
qqci(rnorm(1000),zero=TRUE)
qqci(rnorm(1000),zero=TRUE,standardise=TRUE)

Run the code above in your browser using DataLab