lm
, glm
, multinom
(in the polr
(in the coxph
(in the lmer
in the lme
in the vcov
and coef
functions. For linear
models, F-tests are calculated; for generalized linear models,
likelihood-ratio chisquare, Wald chisquare, or F-tests are calculated;
for multinomial logit and proportional-odds logit models, likelihood-ratio
tests are calculated. Various test statistics are provided for multivariate
linear models produced by lm
or manova
. Partial-likelihood-ratio tests
or Wald tests are provided for Cox models. Wald chi-square tests are provided for fixed effects in
linear and generalized linear mixed-effects models. Wald chi-square or F tests are provided
in the default case.Anova(mod, ...)
Manova(mod, ...)
## S3 method for class 'lm':
Anova(mod, error, type=c("II","III", 2, 3),
white.adjust=c(FALSE, TRUE, "hc3", "hc0", "hc1", "hc2", "hc4"),
vcov.=NULL, singular.ok, ...)
## S3 method for class 'aov':
Anova(mod, ...)
## S3 method for class 'glm':
Anova(mod, type=c("II","III", 2, 3),
test.statistic=c("LR", "Wald", "F"),
error, error.estimate=c("pearson", "dispersion", "deviance"),
singular.ok, ...)
## S3 method for class 'multinom':
Anova(mod, type = c("II","III", 2, 3), ...)
## S3 method for class 'polr':
Anova(mod, type = c("II","III", 2, 3), ...)
## S3 method for class 'mlm':
Anova(mod, type=c("II","III", 2, 3), SSPE, error.df,
idata, idesign, icontrasts=c("contr.sum", "contr.poly"), imatrix,
test.statistic=c("Pillai", "Wilks", "Hotelling-Lawley", "Roy"),...)
## S3 method for class 'manova':
Anova(mod, ...)
## S3 method for class 'mlm':
Manova(mod, ...)
## S3 method for class 'Anova.mlm':
print(x, ...)
## S3 method for class 'Anova.mlm':
summary(object, test.statistic, univariate=TRUE,
multivariate=TRUE, ...)
## S3 method for class 'summary.Anova.mlm':
print(x, digits = getOption("digits"), ... )
## S3 method for class 'coxph':
Anova(mod, type=c("II","III", 2, 3),
test.statistic=c("LR", "Wald"), ...)
## S3 method for class 'lme':
Anova(mod, type=c("II","III", 2, 3),
vcov.=vcov(mod), singular.ok, ...)
## S3 method for class 'mer':
Anova(mod, type=c("II","III", 2, 3),
test.statistic=c("Chisq", "F"), vcov.=vcov(mod), singular.ok, ...)
## S3 method for class 'merMod':
Anova(mod, type=c("II","III", 2, 3),
test.statistic=c("Chisq", "F"), vcov.=vcov(mod), singular.ok, ...)
## S3 method for class 'svyglm':
Anova(mod, ...)
## S3 method for class 'default':
Anova(mod, type=c("II","III", 2, 3),
test.statistic=c("Chisq", "F"), vcov.=vcov(mod),
singular.ok, ...)
lm
, aov
, glm
, multinom
, polr
mlm
, coxph
, lme
, mer
, merMod
, svyglm
or other suitable model object.lm
model object from which the
error sum of squares and degrees of freedom are to be calculated. For
F-tests for a generalized linear model, a glm
object from which the
dispersion is to be e"II"
, "III"
, 2
, or 3
.TRUE
for type-II tests, and FALSE
for type-III tests (where the tests for models with aliased coefficients
will not be straightforwardly interpretable);
if FALSE
, a model with aliased coef"LR"
(likelihood-ratio), "Wald"
, or "F"
tests; for a Cox
model, whether to calculate "LR"
(partial-likelihood ratio) or
"Wald"
"pearson"
, the default); use the
dispersion estimate in the model object ("dispersion"
), which, e.g., is
fixed to 1FALSE
, the default,
tests use a heteroscedasticity-corrected coefficient
covariance matrix; the various values of the argument specify different corrections.
See the documentation for h
idata
and
specifying the intra-subject design.idata
, idesign
, and
(optionally) icontrasts
, the model matrix for the within-subject design
can be given directly in the form of list of named elements. Each element gives
"Anova.mlm"
to print or summarize.TRUE
for both.default
method, an optional coefficient-covariance matrix or function
to compute a covariance matrix, computed by default by applying the generic vcov
function to the model object.
A similar argument may be suppl"anova"
, or "Anova.mlm"
, which usually is printed.
For objects of class "Anova.mlm"
, there is also a summary
method,
which provides much more detail than the print
method about the MANOVA, including
traditional mixed-model univariate F-tests with Greenhouse-Geisser and Huynh-Feldt
corrections.Anova
finds the test statistics without refitting the model. The svyglm
method simply
calls the default
method and therefore can take the same arguments.
The standard R anova
function calculates sequential ("type-I") tests.
These rarely test interesting hypotheses in unbalanced designs.
A MANOVA for a multivariate linear model (i.e., an object of
class "mlm"
or "manova"
) can optionally include an
intra-subject repeated-measures design.
If the intra-subject design is absent (the default), the multivariate
tests concern all of the response variables.
To specify a repeated-measures design, a data frame is provided defining the repeated-measures factor or
factors
via idata
, with default contrasts given by the icontrasts
argument. An intra-subject model-matrix is generated from the formula
specified by the idesign
argument; columns of the model matrix
corresponding to different terms in the intra-subject model must be orthogonal
(as is insured by the default contrasts). Note that the contrasts given in
icontrasts
can be overridden by assigning specific contrasts to the
factors in idata
. As an alternative, the within-subjects model matrix
can be specified directly via the imatrix
argument.
Manova
is essentially a synonym for Anova
for multivariate linear models.linearHypothesis
, anova
anova.lm
, anova.glm
,
anova.mlm
, anova.coxph
, link[survey]{svyglm}
.## Two-Way Anova
mod <- lm(conformity ~ fcategory*partner.status, data=Moore,
contrasts=list(fcategory=contr.sum, partner.status=contr.sum))
Anova(mod)
## One-Way MANOVA
## See ?Pottery for a description of the data set used in this example.
summary(Anova(lm(cbind(Al, Fe, Mg, Ca, Na) ~ Site, data=Pottery)))
## MANOVA for a randomized block design (example courtesy of Michael Friendly:
## See ?Soils for description of the data set)
soils.mod <- lm(cbind(pH,N,Dens,P,Ca,Mg,K,Na,Conduc) ~ Block + Contour*Depth,
data=Soils)
Manova(soils.mod)
## a multivariate linear model for repeated-measures data
## See ?OBrienKaiser for a description of the data set used in this example.
phase <- factor(rep(c("pretest", "posttest", "followup"), c(5, 5, 5)),
levels=c("pretest", "posttest", "followup"))
hour <- ordered(rep(1:5, 3))
idata <- data.frame(phase, hour)
idata
mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5,
post.1, post.2, post.3, post.4, post.5,
fup.1, fup.2, fup.3, fup.4, fup.5) ~ treatment*gender,
data=OBrienKaiser)
(av.ok <- Anova(mod.ok, idata=idata, idesign=~phase*hour))
summary(av.ok, multivariate=FALSE)
## A "doubly multivariate" design with two distinct repeated-measures variables
## (example courtesy of Michael Friendly)
## See ?WeightLoss for a description of the dataset.
imatrix <- matrix(c(
1,0,-1, 1, 0, 0,
1,0, 0,-2, 0, 0,
1,0, 1, 1, 0, 0,
0,1, 0, 0,-1, 1,
0,1, 0, 0, 0,-2,
0,1, 0, 0, 1, 1), 6, 6, byrow=TRUE)
colnames(imatrix) <- c("WL", "SE", "WL.L", "WL.Q", "SE.L", "SE.Q")
rownames(imatrix) <- colnames(WeightLoss)[-1]
(imatrix <- list(measure=imatrix[,1:2], month=imatrix[,3:6]))
contrasts(WeightLoss$group) <- matrix(c(-2,1,1, 0,-1,1), ncol=2)
(wl.mod<-lm(cbind(wl1, wl2, wl3, se1, se2, se3)~group, data=WeightLoss))
Anova(wl.mod, imatrix=imatrix, test="Roy")
## mixed-effects models examples:
library(nlme)
example(lme)
Anova(fm2)
library(lme4)
example(glmer)
Anova(gm1)
Run the code above in your browser using DataLab