Last chance! 50% off unlimited learning
Sale ends in
Fits an additive model (twoway decomposition) using Tukey's median polish procedure.
medpolish(x, eps = 0.01, maxiter = 10, trace.iter = TRUE,
na.rm = FALSE)
a numeric matrix.
real number greater than 0. A tolerance for convergence: see ‘Details’.
the maximum number of iterations
logical. Should progress in convergence be reported?
logical. Should missing values be removed?
An object of class medpolish
with the following named components:
the fitted constant term.
the fitted row effects.
the fitted column effects.
the residuals.
the name of the dataset.
The model fitted is additive (constant + rows + columns). The
algorithm works by alternately removing the row and column medians,
and continues until the proportional reduction in the sum
of absolute residuals is less than eps
or until there have been maxiter
iterations.
The sum of absolute residuals is printed at
each iteration of the fitting process, if trace.iter
is TRUE
.
If na.rm
is FALSE
the presence of any NA
value in
x
will cause an error, otherwise NA
values are ignored.
medpolish
returns an object of class medpolish
(see below).
There are printing and plotting methods for this
class, which are invoked via by the generics
print
and plot
.
Tukey, J. W. (1977). Exploratory Data Analysis, Reading Massachusetts: Addison-Wesley.
# NOT RUN {
require(graphics)
## 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$residuals)
# }
Run the code above in your browser using DataLab