| 42333 |
ripley |
1 |
% File src/library/stats/man/anova.mlm.Rd
|
| 68948 |
ripley |
2 |
% Part of the R package, https://www.R-project.org
|
| 67599 |
ripley |
3 |
% Copyright 1995-2014 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 33650 |
pd |
6 |
\name{anova.mlm}
|
| 56186 |
murdoch |
7 |
\alias{anova.mlm}
|
| 63605 |
ripley |
8 |
%\alias{anova.mlmlist}
|
| 35270 |
ripley |
9 |
\title{Comparisons between Multivariate Linear Models}
|
| 33650 |
pd |
10 |
\description{
|
| 61433 |
ripley |
11 |
Compute a (generalized) analysis of variance table for one or more
|
|
|
12 |
multivariate linear models.
|
| 33650 |
pd |
13 |
}
|
|
|
14 |
\usage{
|
| 40110 |
ripley |
15 |
\method{anova}{mlm}(object, \dots,
|
| 62209 |
hornik |
16 |
test = c("Pillai", "Wilks", "Hotelling-Lawley", "Roy",
|
|
|
17 |
"Spherical"),
|
| 44243 |
ripley |
18 |
Sigma = diag(nrow = p), T = Thin.row(proj(M) - proj(X)),
|
| 62209 |
hornik |
19 |
M = diag(nrow = p), X = ~0,
|
| 46382 |
pd |
20 |
idata = data.frame(index = seq_len(p)), tol = 1e-7)
|
| 33650 |
pd |
21 |
}
|
|
|
22 |
\arguments{
|
| 36648 |
ripley |
23 |
\item{object}{an object of class \code{"mlm"}.}
|
|
|
24 |
\item{\dots}{further objects of class \code{"mlm"}.}
|
| 68055 |
ripley |
25 |
\item{test}{choice of test statistic (see below). Can be abbreviated.}
|
| 40110 |
ripley |
26 |
\item{Sigma}{(only relevant if \code{test == "Spherical"}). Covariance
|
| 35270 |
ripley |
27 |
matrix assumed proportional to \code{Sigma}.}
|
| 36648 |
ripley |
28 |
\item{T}{transformation matrix. By default computed from \code{M} and
|
| 61433 |
ripley |
29 |
\code{X}.}
|
| 36648 |
ripley |
30 |
\item{M}{formula or matrix describing the outer projection (see below).}
|
|
|
31 |
\item{X}{formula or matrix describing the inner projection (see below).}
|
|
|
32 |
\item{idata}{data frame describing intra-block design.}
|
| 47258 |
ripley |
33 |
% avoid Matrix's grab of qr.
|
| 46382 |
pd |
34 |
\item{tol}{tolerance to be used in deciding if the residuals are
|
| 49567 |
ripley |
35 |
rank-deficient: see \code{\link{qr}}.}
|
| 33650 |
pd |
36 |
}
|
|
|
37 |
\details{
|
|
|
38 |
The \code{anova.mlm} method uses either a multivariate test statistic for
|
|
|
39 |
the summary table, or a test based on sphericity assumptions (i.e.
|
|
|
40 |
that the covariance is proportional to a given matrix).
|
|
|
41 |
|
|
|
42 |
For the multivariate test, Wilks' statistic is most popular in the
|
| 35270 |
ripley |
43 |
literature, but the default Pillai--Bartlett statistic is
|
| 40110 |
ripley |
44 |
recommended by Hand and Taylor (1987). See
|
| 40284 |
ripley |
45 |
\code{\link{summary.manova}} for further details.
|
| 33650 |
pd |
46 |
|
|
|
47 |
For the \code{"Spherical"} test, proportionality is usually with the
|
| 74363 |
maechler |
48 |
identity matrix but a different matrix can be specified using \code{Sigma}.
|
| 35270 |
ripley |
49 |
Corrections for asphericity known as the Greenhouse--Geisser,
|
|
|
50 |
respectively Huynh--Feldt, epsilons are given and adjusted \eqn{F} tests are
|
| 33650 |
pd |
51 |
performed.
|
|
|
52 |
|
|
|
53 |
It is common to transform the observations prior to testing. This
|
| 61433 |
ripley |
54 |
typically involves
|
| 33650 |
pd |
55 |
transformation to intra-block differences, but more complicated
|
|
|
56 |
within-block designs can be encountered,
|
| 36648 |
ripley |
57 |
making more elaborate transformations necessary. A
|
| 33650 |
pd |
58 |
transformation matrix \code{T} can be given directly or specified as
|
|
|
59 |
the difference between two projections onto the spaces spanned by
|
|
|
60 |
\code{M} and \code{X}, which in turn can be given as matrices or as
|
|
|
61 |
model formulas with respect to \code{idata} (the tests will be
|
|
|
62 |
invariant to parametrization of the quotient space \code{M/X}).
|
| 61433 |
ripley |
63 |
|
| 35270 |
ripley |
64 |
As with \code{anova.lm}, all test statistics use the SSD matrix from
|
| 33650 |
pd |
65 |
the largest model considered as the (generalized) denominator.
|
| 35277 |
pd |
66 |
|
|
|
67 |
Contrary to other \code{anova} methods, the intercept is not excluded
|
| 36648 |
ripley |
68 |
from the display in the single-model case. When contrast
|
| 35277 |
pd |
69 |
transformations are involved, it often makes good sense to test for a
|
|
|
70 |
zero intercept.
|
| 33650 |
pd |
71 |
}
|
|
|
72 |
\value{
|
|
|
73 |
An object of class \code{"anova"} inheriting from class \code{"data.frame"}
|
|
|
74 |
}
|
| 40110 |
ripley |
75 |
\note{
|
|
|
76 |
The Huynh--Feldt epsilon differs from that calculated by SAS (as of
|
| 65208 |
hornik |
77 |
v.\sspace{}8.2) except when the DF is equal to the number of observations
|
| 40110 |
ripley |
78 |
minus one. This is believed to be a bug in SAS, not in \R.
|
|
|
79 |
}
|
| 33650 |
pd |
80 |
|
|
|
81 |
\references{
|
|
|
82 |
Hand, D. J. and Taylor, C. C. (1987)
|
|
|
83 |
\emph{Multivariate Analysis of Variance and Repeated Measures.}
|
|
|
84 |
Chapman and Hall.
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
%% Probably use example from Baron/Li
|
| 40110 |
ripley |
88 |
\seealso{
|
|
|
89 |
\code{\link{summary.manova}}
|
|
|
90 |
}
|
| 33650 |
pd |
91 |
\examples{
|
| 41508 |
ripley |
92 |
require(graphics)
|
|
|
93 |
utils::example(SSD) # Brings in the mlmfit and reacttime objects
|
| 33650 |
pd |
94 |
|
| 35277 |
pd |
95 |
mlmfit0 <- update(mlmfit, ~0)
|
| 33650 |
pd |
96 |
|
|
|
97 |
### Traditional tests of intrasubj. contrasts
|
|
|
98 |
## Using MANOVA techniques on contrasts:
|
| 61160 |
ripley |
99 |
anova(mlmfit, mlmfit0, X = ~1)
|
| 33650 |
pd |
100 |
|
|
|
101 |
## Assuming sphericity
|
| 61433 |
ripley |
102 |
anova(mlmfit, mlmfit0, X = ~1, test = "Spherical")
|
| 33650 |
pd |
103 |
|
|
|
104 |
|
|
|
105 |
### tests using intra-subject 3x2 design
|
| 61160 |
ripley |
106 |
idata <- data.frame(deg = gl(3, 1, 6, labels = c(0, 4, 8)),
|
|
|
107 |
noise = gl(2, 3, 6, labels = c("A", "P")))
|
| 33650 |
pd |
108 |
|
| 44243 |
ripley |
109 |
anova(mlmfit, mlmfit0, X = ~ deg + noise,
|
|
|
110 |
idata = idata, test = "Spherical")
|
|
|
111 |
anova(mlmfit, mlmfit0, M = ~ deg + noise, X = ~ noise,
|
| 61160 |
ripley |
112 |
idata = idata, test = "Spherical" )
|
| 44243 |
ripley |
113 |
anova(mlmfit, mlmfit0, M = ~ deg + noise, X = ~ deg,
|
| 61160 |
ripley |
114 |
idata = idata, test = "Spherical" )
|
| 33650 |
pd |
115 |
|
| 61168 |
ripley |
116 |
f <- factor(rep(1:2, 5)) # bogus, just for illustration
|
| 35277 |
pd |
117 |
mlmfit2 <- update(mlmfit, ~f)
|
| 44243 |
ripley |
118 |
anova(mlmfit2, mlmfit, mlmfit0, X = ~1, test = "Spherical")
|
|
|
119 |
anova(mlmfit2, X = ~1, test = "Spherical")
|
| 61433 |
ripley |
120 |
# one-model form, eqiv. to previous
|
| 35277 |
pd |
121 |
|
| 33650 |
pd |
122 |
### There seems to be a strong interaction in these data
|
|
|
123 |
plot(colMeans(reacttime))
|
|
|
124 |
}
|
|
|
125 |
\keyword{regression}
|
|
|
126 |
\keyword{models}
|
| 35277 |
pd |
127 |
\keyword{multivariate}
|