Quantile-comparison plots
qqfun(
x,
distribution = "norm",
ylab = deparse(substitute(x)),
xlab = paste(distribution, "quantiles"),
main = NULL,
las = par("las"),
envelope = 0.95,
labels = FALSE,
col = palette()[4],
lcol = palette()[2],
xlim = NULL,
ylim = NULL,
lwd = 1,
pch = 1,
bg = palette()[4],
cex = 0.4,
line = c("quartiles", "robust", "none"),
...
)
These functions are used only for their side effect (to make a graph).
vector of numeric values.
root name of comparison distribution -- e.g., norm
for the normal distribution; t
for the t-distribution.
label for vertical (empirical quantiles) axis.
label for horizontal (comparison quantiles) axis.
label for plot.
if 0
, ticks labels are drawn parallel to the axis; set to 1
for horizontal labels (see graphics::par
).
confidence level for point-wise confidence envelope, or FALSE
for no envelope.
vector of point labels for interactive point identification, or FALSE
for no labels.
color for points; the default is the fourth entry in the current color palette (see grDevices::palette
and graphics::par
).
color for lines; the default is the second entry as above.
the x limits (x1, x2) of the plot. Note that x1 > x2 is allowed and leads to a reversed axis.
the y limits of the plot.
line width; default is 1
(see graphics::par
). Confidence envelopes are drawn at half this line width.
plotting character for points; default is 1
(a circle, see graphics::par
).
background color of points.
factor for expanding the size of plotted symbols; the default is `.4.
"quartiles"
to pass a line through the quartile-pairs, or "robust"
for a robust-regression line; the latter uses the rlm
function in the MASS
package. Specifying line = "none"
suppresses the line.
arguments such as df
to be passed to the appropriate quantile function.
John Fox, Jing Hua Zhao
Plots empirical quantiles of a variable against theoretical quantiles of a comparison distribution.
Draws theoretical quantile-comparison plots for variables and for studentized residuals from a linear model. A comparison line is drawn on the plot either through the quartiles of the two distributions, or by robust regression.
Any distribution for which quantile and density functions exist in R (with prefixes q
and d
, respectively) may be used. Studentized residuals are plotted against the appropriate t-distribution.
This is adapted from car::qq.plot
with different values for points and lines, more options, more transparent code and examples in the current setting. Another similar but sophisticated function is lattice::qqmath
.
davison03gap
leemis08gap
stats::qqnorm
, qqunif
, gcontrol2
if (FALSE) {
p <- runif(100)
alpha <- 1/log(10)
qqfun(p,dist="unif")
qqfun(-log10(p),dist="exp",rate=alpha,pch=21)
library(car)
qq.plot(p,dist="unif")
qq.plot(-log10(p),dist="exp",rate=alpha)
library(lattice)
qqmath(~ -log10(p), distribution = function(p) qexp(p,rate=alpha))
}
Run the code above in your browser using DataLab