We generalize function qqplot
from package stats to
be applicable to distribution and probability model objects, as well as
to estimate objects. In this context,
qqplot
produces a QQ plot of data (argument x
) against
a (model) distribution. If the second argument is of class 'Estimate'
,
qqplot
looks at the estimate.call
-slot and checks whether
it can use an argument ParamFamily
to conclude on the model
distribution. Graphical parameters may be given as arguments to
qqplot
.
In all title and label arguments, if withSubst
is TRUE
,
the following patterns are substituted:
"%C"
class of argument x
"%A"
deparsed argument x
"%D"
time/date-string when the plot was generated
qqplot(x, y, ...)
# S4 method for ANY,UnivariateDistribution
qqplot(x,y,
n = length(x), withIdLine = TRUE,
withConf = TRUE, withConf.pw = withConf, withConf.sim = withConf,
plot.it = TRUE, datax = FALSE, xlab = deparse(substitute(x)),
ylab = deparse(substitute(y)),
..., width = 10, height = 5.5, withSweave = getdistrOption("withSweave"),
mfColRow = TRUE, n.CI = n, with.lab = FALSE, lab.pts = NULL, which.lbs = NULL,
which.Order = NULL, which.nonlbs = NULL, attr.pre = FALSE, order.traf = NULL,
col.IdL = "red", lty.IdL = 2, lwd.IdL = 2, alpha.CI = .95,
exact.pCI = (n
As for function qqplot
from package stats: a
list with components
The x coordinates of the points that were/would be plotted
The corresponding quantiles of the second distribution,
including NA
s.
A matrix with the lower and upper confidence bounds
(computed by qqbounds
).
logical vector of length 2.
(elements crit
and err
are taken from the return
value(s) of qqbounds
).
data to be checked for compatibility with distribution/model y
.
object of class "UnivariateDistribution"
or of
class "ProbFamily"
.
numeric; assumed sample size (by default length of x
).
logical; shall line y = x
be plotted in?
logical; shall confidence lines be plotted?
logical; shall pointwise confidence lines be plotted?
logical; shall simultaneous confidence lines be plotted?
logical; shall be plotted at all (inherited from
qqplot
)?
logical; shall data be plotted on x-axis?
x-label
y-label
further parameters for method qqplot
with signature
ANY,UnivariateDistribution
or with function plot
width (in inches) of the graphics device opened
height (in inches) of the graphics device opened
logical: if TRUE
(for working with Sweave
)
no extra device is opened and height/width are not set
shall default partition in panels be used --- defaults to TRUE
numeric; number of points to be used for confidence interval
logical; shall observation labels be plotted in?
character or NULL
; observation labels to be used
logical; do graphical attributes for plotted data refer
to indices prior (TRUE
) or posterior to selection
via arguments which.lbs
, which.Order
, which.nonlbs
(FALSE
)?
integer or NULL
; which observations shall be labelled
integer or NULL
; which of the ordered (remaining)
observations shall be labelled
indices of the observations which should be plotted but
not labelled; either an integer vector with the indices of the observations
to be plotted into graph or NULL
--- then all non-labelled
observations are plotted.
function or NULL
; an optional trafo by which the
observations are ordered (as order(trafo(obs)).
color for the identity line
line type for the identity line
line width for the identity line
confidence level
logical; shall pointwise CIs be determined with exact Binomial distribution?
logical; shall simultaneous CIs be determined with exact Kolmogorov distribution?
logical; shall we use (shortest) asymmetric CIs?
color for the pointwise CI
line type for the pointwise CI
line width for the pointwise CI
symbol for points (for discrete mass points) in pointwise CI
magnification factor for points (for discrete mass points) in pointwise CI
color for the simultaneous CI
line type for the simultaneous CI
line width for the simultaneous CI
symbol for points (for discrete mass points) in simultaneous CI
magnification factor for points (for discrete mass points) in simultaneous CI
logical; should CIs be plotted through additional points (and not only through data points)?
magnification factor for the plotted symbols (for backward
compatibility); it is ignored once col.pts
is specified.
color for the plotted symbols (for backward compatibility); it is
ignored once col.pts
is specified.
size of the points of the second argument plotted, can be a vector;
if argument attr.pre
is TRUE
, it is recycled to the length
of all observations and determines the sizes of all plotted symbols,
i.e., the selection is done within this argument; in this case argument
col.npts
is ignored. If attr.pre
is FALSE
,
cex.pts
is recycled to the number of the observations selected
for labelling and refers to the index ordering after the
selection. Then argument cex.npts
deteremines the sizes
of the shown but non-labelled observations as given in argument
which.nonlbs
.
color of the points of the second argument plotted, can
be a vector as in cex.pts
(with col.npts
as counterpart).
symbol of the points of the second argument plotted, can
be a vector as in cex.pts
(with pch.npts
as counterpart).
color of the non-labelled points of the data
argument
plotted; (may be a vector).
symbol of the non-labelled points of the data
argument
plotted (may be a vector).
size of the non-labelled points of the data
argument
plotted (may be a vector).
magnification factor for the plotted observation labels
color for the plotted observation labels
adj parameter for the plotted observation labels
alpha transparency to be added ex post to colors
col.pch
and col.lbs
; if one-dim and NA all colors are
left unchanged. Otherwise, with usual recycling rules alpha.trsp
gets shorted/prolongated to length the data-symbols to be plotted.
Coordinates of this vector alpha.trsp
with NA are left unchanged,
while for the remaining ones, the alpha channel in rgb space is set
to the respective coordinate value of alpha.trsp
. The non-NA
entries must be integers in [0,255] (0 invisible, 255 opaque).
jittering factor used for discrete distributions.
threshold for jittering: if distance between points is smaller
than jit.tol
, points are considered replicates.
logical; shall we check if all x
-quantiles lie
in support(y)
?
logical; if preceding check TRUE
color of
x
-quantiles if not in support(y)
logical; shall a legend be plotted?
background color for the legend
position for the legend
magnification factor for the legend
character to be prepended to legend text
character to be appended to legend text
nominal coverage probability
logical; if TRUE
additional output to debug confidence bounds.
logical; if TRUE
(default) pattern substitution for
titles and axis lables is used; otherwise no substitution is used.
Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de
signature(x = "ANY", y = "UnivariateDistribution")
:
produces a QQ plot of a dataset x
against the theoretical
quantiles of distribution y
.
signature(x = "ANY", y = "ProbFamily")
:
produces a QQ plot of a dataset x
against the theoretical
quantiles of the model distribution of model y
. Passed through
the ...
argument, all arguments valid for
signature(x = "ANY", y = "UnivariateDistribution")
are also valid for this signature.
signature(x = "ANY", y = "Estimate")
:
produces a QQ plot of a dataset x
against the theoretical
quantiles of the model distribution of the model that can be reconstructed
from the estimator y
; more specifically, it tries to get hand at the
argument 'ParamFamily'
of the esimator's call; if this is available,
internally this model is shifted to the estimated parameter by a call to
modifyModel
, and then this shifted model is used in a call to the
(x = "ANY", y = "UnivariateDistribution")
-method. Passed through
the ...
argument, all arguments valid for
signature(x = "ANY", y = "UnivariateDistribution")
are also valid for this signature.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
qqplot
from package stats -- the standard QQ plot
function, qqplot
from package distr for
comparisons of distributions, and
qqbounds
, used by qqplot
to produce confidence
intervals.
set.seed(123)
x <- rnorm(40,mean=15,sd=30)
qqplot(x, Chisq(df=15))
NF <- NormLocationScaleFamily(mean=15, sd=30)
qqplot(x, NF, with.lab=TRUE, which.Order=1:5, cex.lbs=1.3)
mlE <- MLEstimator(x, NF)
qqplot(x, mlE)
Run the code above in your browser using DataLab