\HeaderA{tmd}{Tukey Mean-Difference Plot}{tmd}
\aliasA{panel.tmd.default}{tmd}{panel.tmd.default}
\aliasA{panel.tmd.qqmath}{tmd}{panel.tmd.qqmath}
\aliasA{prepanel.tmd.default}{tmd}{prepanel.tmd.default}
\aliasA{prepanel.tmd.qqmath}{tmd}{prepanel.tmd.qqmath}
\methaliasA{tmd.formula}{tmd}{tmd.formula}
\methaliasA{tmd.trellis}{tmd}{tmd.trellis}
\keyword{dplot}{tmd}
\begin{Description}\relax
\code{tmd} Creates Tukey Mean-Difference Plots from a trellis object
returned by \code{xyplot}, \code{qq} or \code{qqmath}.  The prepanel
and panel functions are used as appropriate.  The \code{formula}
method for \code{tmd} is provided for convenience, and simply calls
\code{tmd} on the object created by calling \code{xyplot} on that
formula.
\end{Description}
\begin{Usage}
\begin{verbatim}
tmd(object, ...)

## S3 method for class 'trellis':
tmd(object,
    xlab = "mean",
    ylab = "difference",
    panel, 
    prepanel, 
    ...)

prepanel.tmd.qqmath(x,
             f.value = NULL,
             distribution = qnorm,
             qtype = 7,
             groups = NULL,
             subscripts, ...)
panel.tmd.qqmath(x,
             f.value = NULL,
             distribution = qnorm,
             qtype = 7,
             groups = NULL, 
             subscripts, ...)
panel.tmd.default(x, y, groups = NULL, ...)
prepanel.tmd.default(x, y, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] An object of class \code{"trellis"} returned by
\code{xyplot}, \code{qq} or \code{qqmath}.  
\item[\code{xlab}] x label
\item[\code{ylab}] y label
\item[\code{panel}] panel function to be used.  See details below.  
\item[\code{prepanel}] prepanel function.  See details below.  
\item[\code{f.value, distribution, qtype}] see \code{\LinkA{panel.qqmath}{panel.qqmath}}.  
\item[\code{groups, subscripts}] see \code{\LinkA{xyplot}{xyplot}}.  
\item[\code{x, y}] data as passed to panel functions in original call.  
\item[\code{...}] other arguments
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The Tukey Mean-difference plot is produced by modifying the (x,y)
values of each panel as follows: the new coordinates are given by
\code{x=(x+y)/2} and \code{y=y-x}, which are then plotted.  The
default panel function(s) add a reference line at \code{y=0} as well.

\code{tmd} acts on the a \code{"trellis"} object, not on the actual plot
this object would have produced.  As such, it only uses the arguments
supplied to the panel function in the original call, and completely
ignores what the original panel function might have done with this
data.  \code{tmd} uses these panel arguments to set up its own scales
(using its \code{prepanel} argument) and display (using
\code{panel}).  It is thus important to provide suitable prepanel and
panel functions to \code{tmd} depending on the original call.

Such functions currently exist for \code{xyplot}, \code{qq} (the ones
with \code{default} in their name) and \code{qqmath}, as listed in the
usage section above.  These assume the default displays for the
corresponding high-level call.  If unspecified, the code{prepanel} and
\code{panel} arguments default to suitable choices.

\code{tmd} uses the \code{update} method for \code{"trellis"} objects,
which processes all extra arguments supplied to \code{tmd}.
\end{Details}
\begin{Value}
An object of class \code{"trellis"}. The
\code{\LinkA{update}{update}} method can be used to
update components of the object and the
\code{\LinkA{print}{print}} method (usually called by
default) will plot it on an appropriate plotting device.
\end{Value}
\begin{Author}\relax
Deepayan Sarkar \email{Deepayan.Sarkar@R-project.org}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{qq}{qq}}, \code{\LinkA{qqmath}{qqmath}}, \code{\LinkA{xyplot}{xyplot}},
\code{\LinkA{Lattice}{Lattice}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
tmd(qqmath(~height | voice.part, data = singer))
\end{ExampleCode}
\end{Examples}

