\Header{medpolish}{Median Polish of a Matrix}
\alias{plot.medpolish}{medpolish}
\alias{print.medpolish}{medpolish}
\keyword{robust}{medpolish}
\begin{Usage}
\begin{verbatim}
medpolish(x, eps=0.01, maxiter=10, trace.iter = TRUE)

plot(medpolish.obj)
print(medpolish.obj)
\end{verbatim}
\end{Usage}
\begin{Description}
\texttt{medpolish} fits an additive "two-way" (constant + rows + columns)
model to the values given in \texttt{x} using Tukey's
\emph{median polish} procedure.\end{Description}
\begin{Details}
Sweeping out for row and column effects continues
until the proportional reduction in the sum
of absolute residuals is less than \texttt{eps}
or until there have been \texttt{maxiter} iterations.
The sum of absolute residuals is printed at
each iteration of the fitting process, if \texttt{trace.iter} is \texttt{TRUE}.

\texttt{medpolish} returns an object of class \texttt{medpolish} (see below).
There are printing and plotting methods for this
class, which are invoked via by the generics
\texttt{\Link{print}} and \texttt{\Link{plot}}.\end{Details}
\begin{Value}
An object of class \texttt{medpolish} with the following named components:
\begin{ldescription}
\item[\texttt{overall}] the fitted constant term.
\item[\texttt{row}] the fitted row effects.
\item[\texttt{col}] the fitted column effects.
\item[\texttt{residuals}] the residuals.
\item[\texttt{name}] the name of the dataset.
\end{ldescription}
\end{Value}
\begin{References}
Tukey (1977). \emph{E.D.A}; see ref.\ in \texttt{\Link{line}}.\end{References}
\begin{SeeAlso}
\texttt{\Link{median}}; \texttt{\Link{aov}} which for a \emph{mean}
instead of \emph{median} decomposition.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## Deaths from sport parachuting;  from ABC of EDA, p.224:
deaths <-
    rbind(c(14,15,14),
          c( 7, 4, 7),
          c( 8, 2,10),
          c(15, 9,10),
          c( 0, 2, 0))
dimnames(deaths) <- list(c("1-24", "25-74", "75-199", "200++", "NA"),
                         paste(1973:1975))
deaths
(med.d <- medpolish(deaths))
plot(med.d)
## Check decomposition:
all(deaths == med.d$overall + outer(med.d$row,med.d$col, "+") + med.d$resid)
\end{ExampleCode}
\end{Examples}

