Rev 4211 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{B_04_qqmath}\alias{qqmath}\alias{qqmath.formula}\alias{qqmath.numeric}\title{ Q-Q Plot with Theoretical Distribution }\description{Quantile-Quantile plot of a sample and a theoretical distribution}\usage{qqmath(x, data, \dots)\method{qqmath}{formula}(x,data,allow.multiple = is.null(groups) || outer,outer = !is.null(groups),distribution = qnorm,f.value = NULL,auto.key = FALSE,aspect = "fill",panel = lattice.getOption("panel.qqmath"),prepanel = NULL,scales, strip, groups,xlab, xlim, ylab, ylim,drop.unused.levels = lattice.getOption("drop.unused.levels"),\dots,lattice.options = NULL,default.scales = list(),subscripts,subset)\method{qqmath}{numeric}(x, data = NULL, ylab, \dots)}\arguments{\item{x}{The object on which method dispatch is carried out.For the \code{"formula"} method, a formula of the form \code{~ x |g1 * g2 * \ldots}, where \code{x} must be a numeric. For the\code{"numeric"} method, a numeric vector.}\item{data}{For the \code{formula} method, an optional data frame in whichvariables in the formula (as well as \code{groups} and\code{subset}, if any) are to be evaluated. Usualll ignored with awarning in other methods.}\item{distribution}{ a quantile function that takes a vector ofprobabilities as argument and produces the correspondingquantiles. Possible values are \code{qnorm}, \code{qunif} etc.Distributions with other required arguments need to be passed in asuser defined functions.}\item{f.value}{ optional numeric vector of probabilities, quantilescorresponding to which should be plotted. Can also be a function ofa single integer (representing sample size) that returns such anumeric vector. The typical value for this argument is the function\code{ppoints}, which is also the S-PLUS default. If specified, theprobabilities generated by this function is used for the plottedquantiles, using the \code{quantile} function for the sample, andthe function specified as the \code{distribution} argument for thetheoretical distribution.\code{f.value} defaults to \code{NULL}, which has the effect ofusing \code{ppoints} for the quantiles of the theoreticaldistribution, but the exact data values for the sample. This issimilar to what happens for \code{qqnorm}, but different from theS-PLUS default of \code{f.value=ppoints}.For large \code{x}, this argument can be useful in plotting asmaller set of quantiles, which is usually enough to capture thepattern.}\item{panel}{The panel function to be used. Unlike in older versions, thedefault panel function does most of the actual computations and hassupport for grouping. See \code{\link{panel.qqmath}} for details.}\item{allow.multiple, outer, auto.key, aspect, prepanel, scales,strip, groups, xlab, xlim, ylab, ylim, drop.unused.levels,lattice.options, default.scales, subscripts, subset}{ See\code{\link{xyplot}} }\item{\dots}{Further arguments. See corresponding entry in \code{\link{xyplot}}for non-trivial details.}}\value{An object of class \code{"trellis"}. The\code{\link[lattice:update.trellis]{update}} method can be used toupdate components of the object and the\code{\link[lattice:print.trellis]{print}} method (usually called bydefault) will plot it on an appropriate plotting device.}\details{\code{qqmath} produces a Q-Q plot of the given sample and atheoretical distribution. The default behaviour of \code{qqmath} isdifferent from the corresponding S-PLUS function, but is similar to\code{qqnorm}. See the entry for \code{f.value} for specifics.The implementation details are also different from S-PLUS. Inparticular, all the important calculations are done by the panel (andprepanel function) and not \code{qqmath} itself. In fact, both thearguments \code{distribution} and \code{f.value} are passed unchangedto the panel and prepanel function. This allows, among other things,display of grouped Q-Q plots, which are often useful. See the helppage for \code{\link{panel.qqmath}} for further details.This and all other high level Trellis functions have severalarguments in common. These are extensively documented only in thehelp page for \code{xyplot}, which should be consulted to learn moredetailed usage.}\author{Deepayan Sarkar \email{Deepayan.Sarkar@R-project.org}}\seealso{\code{\link{xyplot}}, \code{\link{panel.qqmath}},\code{\link{panel.qqmathline}}, \code{\link{prepanel.qqmathline}},\code{\link{Lattice}}, \code{\link{quantile}}}\examples{qqmath(~ rnorm(100), distribution = function(p) qt(p, df = 10))qqmath(~ height | voice.part, aspect = "xy", data = singer,prepanel = prepanel.qqmathline,panel = function(x, ...) {panel.qqmathline(x, ...)panel.qqmath(x, ...)})vp.comb <-factor(sapply(strsplit(as.character(singer$voice.part), split = " "),"[", 1),levels = c("Bass", "Tenor", "Alto", "Soprano"))vp.group <-factor(sapply(strsplit(as.character(singer$voice.part), split = " "),"[", 2))qqmath(~ height | vp.comb, data = singer,groups = vp.group, auto.key = list(space = "right"),aspect = "xy",prepanel = prepanel.qqmathline,panel = function(x, ...) {panel.qqmathline(x, ...)panel.qqmath(x, ...)})}\keyword{dplot}