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.
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,
...
)
Produces a QQ-plot with simulation-based confidence bands
a vector of values to compare
a function accepting a single argument to generate samples from the comparison distribution, the default is rnorm
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.
the number of simulations to generate: the more simulations, the more accurate the confidence bands. Default is 100
logical, whether to zero the plot across the x-axis. Default is FALSE
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)
vector of probabilities giving which sample-based empirical quantiles to add to the plot. Default is c(0.025,0.975)
positive numeric, the width of line to plot, default is 2
colour of line to plot, default is red
character, the label for the x-axis
character, the label for the y-axis
controls transparency of samples (coloured blue)
colour of confidence band lines, default is black
width of confidence band lines, default is 1
additional arguments to pass to matplot
qqci(rnorm(1000))
qqci(rnorm(1000),zero=TRUE)
qqci(rnorm(1000),zero=TRUE,standardise=TRUE)
Run the code above in your browser using DataLab