Learn R Programming

QTLRel (version 0.1)

qqPlot: Quantile-Quantile Plots

Description

Quantile-Quantile Plots With the Ability to Draw Confidence Bands.

Usage

qqPlot(y, x = "norm", ...,
   xlab = if(is.numeric(x)) deparse(substitute(x)) else x,
   ylab = deparse(substitute(y)), main = "Q-Q Plot",
   type = "p", col = 1, lty = 2, lwd=1, pch=1, cex = 0.7,
   plot.it = TRUE, confidence = .95,
   qqline = c("observed", "expected", "none"))

Arguments

y
a numeric vector of data values.
x
either a numeric vector of data values, or a character string naming a distribution function such as "norm".
...
parameters passed to the distribution specified by x (if non-numerical).
xlab
a label for the x axis.
ylab
a label for the y axis.
main
a main title for the plot.
type
1-character string giving the type of plot desired.
col
color for points and lines.
lty
line type.
lwd
line width.
pch
plotting character for points.
cex
factor for expanding the size of plotted symbols.
plot.it
whether or not to draw a plot. if plotting, points outside the confidence bands will be indicated by different a color.
confidence
confidence level for the confidence band, or FALSE for no band.
qqline
whether or not to draw a reference line. if "observed", the line passes through the first and third observed quartiles; if "expected", the point (x,y) is expected to fall on the line if x and y follow the same distribution; if "none", no reference line is

Value

  • xquantiles of x
  • yquantiles of y
  • lower, upperlower and upper limits if confidence is specified

Details

If x is numeric, a two-sample test of the null hypothesis that x and y were drawn from the same continuous distribution is performed. Alternatively, x can be a character string naming a continuous distribution function. In such a case, a one-sample test is carried out of the null that y was draw from distribution x with parameters specified by "...".

References

George Marsaglia, Wai Wan Tsang and Jingbo Wang (2003), Evaluating Kolmogorov's distribution. Journal of Statistical Software 8 (18): 1-4. Vijayan N. Nair (1982). Q-Q plots with confidence bands for comparing several populations. William J. Conover (1971). Practical Nonparametric Statistics. New York: John Wiley & Sons.

See Also

ks.test.

Examples

Run this code
par(mfrow=c(1,2))
x<- rnorm(200, mean=0.7,sd=2); y<- rnorm(200, sd=2)
qqPlot(y,x,qqline="exp")
qqPlot(y=y,x="norm",sd=2)
ks.test(x,y)

Run the code above in your browser using DataLab