Description Usage Arguments Details Value Warning Note Author(s) See Also Examples
Compute an ANOVA-like table with tests of random-effect terms in the model.
Each random-effect term is reduced or removed and likelihood ratio tests of
model reductions are presented in a form similar to that of
drop1
.
rand
is an alias for ranova
.
1 2 3 |
model |
a linear mixed effect model fitted with |
reduce.terms |
if |
... |
currently ignored |
If the model is fitted with REML the tests are REML-likelihood ratio tests.
A random-effect term of the form (f1 + f2 | gr)
is reduced to
terms of the form (f2 | gr)
and (f1 | gr)
and these reduced
models are compared to the original model.
If reduce.terms
is FALSE
(f1 + f2 | gr)
is removed
instead.
A random-effect term of the form (f1 | gr)
is reduced to (1 | gr)
(unless reduce.terms
is FALSE
).
A random-effect term of the form (1 | gr)
is not reduced but
simply removed.
A random-effect term of the form (0 + f1 | gr)
or (-1 + f1 | gr)
is reduced (if reduce.terms = TRUE
) to (1 | gr)
.
A random-effect term of the form (1 | gr1/gr2)
is automatically
expanded to two terms: (1 | gr2:gr1)
and (1 | gr1)
using
findbars
.
In this exposition it is immaterial whether f1
and f2
are
factors or continuous variables.
an ANOVA-like table with single term deletions of random-effects
inheriting from class anova
and data.frame
with the columns:
npar |
number of model parameters. |
logLik |
the log-likelihood for the model. Note that this is the REML-logLik if the model is fitted with REML. |
AIC |
the AIC for the model evaluated as |
LRT |
the likelihood ratio test statistic; twice the difference in log-likelihood, which is asymptotically chi-square distributed. |
Df |
degrees of freedom for the likelihood ratio test: the difference in number of model parameters. |
Pr(>Chisq) |
the p-value. |
In certain cases tests of non-nested models may be generated. An example
is when (0 + poly(x, 2) | gr)
is reduced (the default) to (1 | gr)
.
To our best knowledge non-nested model comparisons are only generated in
cases which are statistical nonsense anyway (such as in this example where
the random intercept is suppressed).
Note that anova
can be used to compare two models and will often
be able to produce the same tests as ranova
. This is, however, not always the
case as illustrated in the examples.
Rune Haubo B. Christensen and Alexandra Kuznetsova
drop1
for tests of marginal
fixed-effect terms and
anova
for usual anova tables for fixed-effect terms.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # Test reduction of (Days | Subject) to (1 | Subject):
fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
ranova(fm1) # 2 df test
# This test can also be achieved with anova():
fm2 <- lmer(Reaction ~ Days + (1|Subject), sleepstudy)
anova(fm1, fm2, refit=FALSE)
# Illustrate reduce.test argument:
# Test removal of (Days | Subject):
ranova(fm1, reduce.terms = FALSE) # 3 df test
# The likelihood ratio test statistic is in this case:
fm3 <- lm(Reaction ~ Days, sleepstudy)
2*c(logLik(fm1, REML=TRUE) - logLik(fm3, REML=TRUE)) # LRT
# anova() is not always able to perform the same tests as ranova(),
# for example:
anova(fm1, fm3, refit=FALSE) # compares REML with ML and should not be used
anova(fm1, fm3, refit=TRUE) # is a test of ML fits and not what we seek
# Also note that the lmer-fit needs to come first - not an lm-fit:
# anova(fm3, fm1) # does not work and gives an error
# ranova() may not generate all relevant test:
# For the following model ranova() indicates that we should not reduce
# (TVset | Assessor):
fm <- lmer(Coloursaturation ~ TVset * Picture + (TVset | Assessor), data=TVbo)
ranova(fm)
# However, a more appropriate model is:
fm2 <- lmer(Coloursaturation ~ TVset * Picture + (1 | TVset:Assessor), data=TVbo)
anova(fm, fm2, refit=FALSE)
# fm and fm2 has essentially the same fit to data but fm uses 5 parameters
# more than fm.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.