Description Usage Arguments Value Note Author(s) References See Also Examples
When only one fitted model object is present, a data frame with the
numerator degrees of freedom, denominator degrees of
freedom, F-values, and P-values for Wald tests for the terms in the
model (when Terms
and L
are NULL
), a combination
of model terms (when Terms
in not NULL
), or linear
combinations of the model coefficients (when L
is not
NULL
). Otherwise, when multiple fitted objects are being
compared, a data frame with the degrees of freedom, the (restricted)
log-likelihood, the Akaike Information Criterion (AIC), and the
Bayesian Information Criterion (BIC) of each object is returned. If
test=TRUE
, whenever two consecutive objects have different
number of degrees of freedom, a likelihood ratio statistic with the
associated p-value is included in the returned data frame.
1 2 3 4 |
object |
an object inheriting from class |
... |
other optional fitted model objects inheriting from
classes |
test |
an optional logical value controlling whether likelihood
ratio tests should be used to compare the fitted models represented
by |
type |
an optional character string specifying the type of sum of
squares to be used in F-tests for the terms in the model. If
|
adjustSigma |
an optional logical value. If |
Terms |
an optional integer or character vector specifying which
terms in the model should be jointly tested to be zero using a Wald
F-test. If given as a character vector, its elements must correspond
to term names; else, if given as an integer vector, its elements must
correspond to the order in which terms are included in the
model. This argument is only used when a single fitted object is
passed to the function. Default is |
L |
an optional numeric vector or array specifying linear
combinations of the coefficients in the model that should be tested
to be zero. If given as an array, its rows define the linear
combinations to be tested. If names are assigned to the vector
elements (array columns), they must correspond to coefficients
names and will be used to map the linear combination(s) to the
coefficients; else, if no names are available, the vector elements
(array columns) are assumed in the same order as the coefficients
appear in the model. This argument is only used when a single fitted
object is passed to the function. Default is |
x |
an object inheriting from class |
verbose |
an optional logical value. If |
a data frame inheriting from class "anova.lme"
.
Likelihood comparisons are not meaningful for objects fit using restricted maximum likelihood and with different fixed effects.
José Pinheiro and Douglas Bates bates@stat.wisc.edu
Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer.
gls
, gnls
, nlme
,
lme
, AIC
, BIC
,
print.anova.lme
,
logLik.lme
,
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 35 36 37 38 39 40 41 42 43 | fm1 <- lme(distance ~ age, Orthodont, random = ~ age | Subject)
anova(fm1)
fm2 <- update(fm1, random = pdDiag(~age))
anova(fm1, fm2)
## Pinheiro and Bates, pp. 251-254 ------------------------------------------
fm1Orth.gls <- gls(distance ~ Sex * I(age - 11), Orthodont,
correlation = corSymm(form = ~ 1 | Subject),
weights = varIdent(form = ~ 1 | age))
fm2Orth.gls <- update(fm1Orth.gls,
corr = corCompSymm(form = ~ 1 | Subject))
## anova.gls examples:
anova(fm1Orth.gls, fm2Orth.gls)
fm3Orth.gls <- update(fm2Orth.gls, weights = NULL)
anova(fm2Orth.gls, fm3Orth.gls)
fm4Orth.gls <- update(fm3Orth.gls, weights = varIdent(form = ~ 1 | Sex))
anova(fm3Orth.gls, fm4Orth.gls)
# not in book but needed for the following command
fm3Orth.lme <- lme(distance ~ Sex*I(age-11), data = Orthodont,
random = ~ I(age-11) | Subject,
weights = varIdent(form = ~ 1 | Sex))
# Compare an "lme" object with a "gls" object (test would be non-sensical!)
anova(fm3Orth.lme, fm4Orth.gls, test = FALSE)
## Pinheiro and Bates, pp. 222-225 ------------------------------------------
op <- options(contrasts = c("contr.treatment", "contr.poly"))
fm1BW.lme <- lme(weight ~ Time * Diet, BodyWeight, random = ~ Time)
fm2BW.lme <- update(fm1BW.lme, weights = varPower())
# Test a specific contrast
anova(fm2BW.lme, L = c("Time:Diet2" = 1, "Time:Diet3" = -1))
## Pinheiro and Bates, pp. 352-365 ------------------------------------------
fm1Theo.lis <- nlsList(
conc ~ SSfol(Dose, Time, lKe, lKa, lCl), data=Theoph)
fm1Theo.lis
fm1Theo.nlme <- nlme(fm1Theo.lis)
fm2Theo.nlme <- update(fm1Theo.nlme, random= pdDiag(lKe+lKa+lCl~1) )
fm3Theo.nlme <- update(fm2Theo.nlme, random= pdDiag( lKa+lCl~1) )
# Comparing the 3 nlme models
anova(fm1Theo.nlme, fm3Theo.nlme, fm2Theo.nlme)
options(op) # (set back to previous state)
|
numDF denDF F-value p-value
(Intercept) 1 80 3096.4871 <.0001
age 1 80 85.8464 <.0001
Model df AIC BIC logLik Test L.Ratio p-value
fm1 1 6 454.6367 470.6173 -221.3183
fm2 2 5 453.3146 466.6318 -221.6573 1 vs 2 0.6778943 0.4103
Model df AIC BIC logLik Test L.Ratio p-value
fm1Orth.gls 1 14 452.5468 489.5683 -212.2734
fm2Orth.gls 2 9 449.9724 473.7719 -215.9862 1 vs 2 7.425576 0.1909
Model df AIC BIC logLik Test L.Ratio p-value
fm2Orth.gls 1 9 449.9724 473.7719 -215.9862
fm3Orth.gls 2 6 445.7572 461.6236 -216.8786 1 vs 2 1.784873 0.6182
Model df AIC BIC logLik Test L.Ratio p-value
fm3Orth.gls 1 6 445.7572 461.6236 -216.8786
fm4Orth.gls 2 7 436.1887 454.6994 -211.0943 1 vs 2 11.56859 7e-04
Model df AIC BIC logLik
fm3Orth.lme 1 9 429.5225 453.3220 -205.7612
fm4Orth.gls 2 7 436.1887 454.6994 -211.0943
F-test for linear combination(s)
Time:Diet2 Time:Diet3
1 -1
numDF denDF F-value p-value
1 1 157 2.862607 0.0926
Call:
Model: conc ~ SSfol(Dose, Time, lKe, lKa, lCl) | Subject
Data: Theoph
Coefficients:
lKe lKa lCl
6 -2.307332 0.1516234 -2.973242
7 -2.280370 -0.3860511 -2.964335
8 -2.386437 0.3188339 -3.069111
11 -2.321530 1.3478239 -2.860397
3 -2.508073 0.8975422 -3.229965
2 -2.286108 0.6640568 -3.106317
4 -2.436494 0.1582638 -3.286087
9 -2.446088 2.1821879 -3.420774
12 -2.248326 -0.1828442 -3.170158
10 -2.604148 -0.3631216 -3.428271
1 -2.919614 0.5751612 -3.915857
5 -2.425486 0.3862853 -3.132600
Degrees of freedom: 132 total; 96 residual
Residual standard error: 0.7001921
Warning message:
In (function (model, data = sys.frame(sys.parent()), fixed, random, :
Iteration 2, LME step: nlminb() did not converge (code = 1). Do increase 'msMaxIter'!
Model df AIC BIC logLik Test L.Ratio p-value
fm1Theo.nlme 1 10 366.6421 395.4702 -173.3211
fm3Theo.nlme 2 6 366.0429 383.3397 -177.0214 1 vs 2 7.400746 0.1162
fm2Theo.nlme 3 7 368.0470 388.2266 -177.0235 2 vs 3 0.004123 0.9488
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.