twoway.formula
)
and matrices (the default method).
twoway(x, trim=.5, iter=6, eps=<<see below>>, print=F) twoway.default(x, trim=.5, iter=6, eps=<<see below>>, print=F)
NA
s) are allowed.
Rows represent the levels of one of the factors and columns represent the
levels of the other factor.
trim=0
will cause
analysis by means, .25 by midmeans, etc.
eps
is given, the algorithm will
iterate until the maximum change in row or column effects is
less than
eps
. The default is to iterate until the specified number
of iterations or until converged to the accuracy of the
machine arithmetic. It is not always possible to converge
to a unique answer.
TRUE
, the maximum change in row/column effects in
the last iteration is printed.
resid
,
row
,
col
,
and
grand
, such that
x[i,j]
equals
grand + row[i] + col[j] + resid[i,j]
Missing values are omitted in the computations.
Results are currently computed to single-precision accuracy only.
With the default
trim=.5
a median polish is performed on the table.
Median polish is a simple and very useful technique for detecting
anomalous behavior in a two-way table.
Although not particularly efficient when the errors have the Gaussian
(Normal) distribution, median polish has the highest breakdown possible.
Outliers in a two-way (or higher dimensional) table can be very hard
to detect without a procedure with at least a moderate breakdown point.
There is no guarantee that median polish will converge for a particular
table, but in practice convergence is often achieved after 3 or 4
iterations. Even when there is not convergence, the result will be close
to the converged result. Although the median is the L1 (Least Absolute
Deviations) solution for the location problem, median polish usually
has a sum of absolute deviations greater than an L1 solution, however,
it has the good robustness properties that L1 enjoys.
When
trim=0
, a least squares fit is found. If there are no missing
values, then this is the fit with which an Analysis of Variance works.
Hoaglin, D. C., Mosteller, F. and Tukey, J. W., editors (1983).
Understanding Robust and Exploratory Data Analysis.
Wiley, New York.
Mosteller, F. and Tukey, J. W. (1977).
Data Analysis and Regression.
Addison-Wesley, Reading, Mass.
Velleman, P. F. and Hoaglin, D. C. (1981).
Applications, Basics, and Computing of Exploratory Data Analysis.
Duxbury, Boston.
twoway(cereal.attitude, trim=.25) # analysis by midmeans