qqnorm
Normal Quantile-Quantile Plots
Description
Produces data for a Normal Quantile-Quantile plot, which is
plot of the order data values versus quantiles from a Normal
distribution.
The displayed points should follow a linear shape if the data values
are from Normal distribution.
The qqnorm function is generic (see Methods);
method functions can be written to handle specific classes of data.
Usage
qqnorm(x, ...)
## Default S3 method:
qqnorm(y, ylim, main="Normal Q-Q Plot",
xlab="Theoretical Quantiles", ylab="Sample Quantiles",
plot.it=TRUE, datax = FALSE, ...)
Arguments
y |
a numeric vector for qqnorm.default, an object for
qqnorm.
Missing values, (NA), are allowed.
There should be at least one value that is not (NA).
|
ylim |
numeric of length 2 giving the y limits for the plot.
|
main |
overall title for the plot.
|
xlab, ylab |
character strings for axis labels. The default, if datax is TRUE,
is the argument passed as x for the y-axis,
and the argument passed as y for the x-axis. These are
switched if datax is FALSE.
|
plot.it |
if FALSE, qqplot.default and qqnorm return
a non-visible list with components x and y. If TRUE, they return the
coordinates of the points that would have been plotted.
|
datax |
if TRUE, data y goes on the x-axis; if FALSE
data y goes on the y-axis. And the axis labels will change at the same time.
|
... |
Graphical parameters may also be supplied as arguments to
this function (see par ).
In particular these functions can take arguments type and log
to control plot type and logarithmic axes (see
plot.default
).
Use the arguments xlim and ylim to control the limits of the plot
region.
In addition, the high-level graphics arguments described under plot.default and the arguments to title may be supplied to this function.
|
Details
The function qqnorm takes a single vector of data and an optional vector of weights for a normal (Gaussian) probability plot.
When plot.it is FALSE, it returns a non-visible list with 2 components. The component y comes from the argument Y with value NA is striped. The component x is the result of qnorm(ppoints(length(y)))[order(order(y))] where NA value in argument y has been striped, but the NA value in argument y is placed in the same position to the result components. And, if datax is TRUE, the components x and y should exchange its value.
Value
if plot.it is FALSE, qqnorm returns a non-visible list with components
x and y.
If plot.it is TRUE, returns the coordinates of the points that would have been plotted.
Side Effects
if plot.it=TRUE, a Normal quantile-quantile plot is produced
on the current graphics device.
Background
QQplots are used to assess whether data have a particular distribution, or
whether two datasets have the same distribution. If the distributions are
the same, then the plot will be approximately a straight line.
The extreme points have more variability than points toward the center.
A plot with a "U" shape means that one distribution is skewed relative
to the other. An "S" shape implies that one distribution has longer
tails than the other. In the default configuration a plot from qqnorm
that is bent down on the left and bent up on the right means that the
data have longer tails than the Gaussian.
References
Chambers, J. M., Cleveland, W. S., Kleiner, B. and Tukey, P. A. (1983).
Graphical Methods for Data Analysis.
Wadsworth, Belmont, California.
Hoaglin, D. C., Mosteller, F. and Tukey, J. W., editors (1983).
Understanding Robust and Exploratory Data Analysis.
Wiley, New York.
See Also
Examples
set.seed(493)
my.sample <- rt(100, 5)
lab <- "100 observations from a t-distribution with 5 df"
qqnorm(my.sample, main = lab, sub = "QQ Plot with Line")
qqline(my.sample)