anova.gls.Rd
When only one fitted model object is present, a data frame with the
numerator 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.
# S3 method for class 'gls'
anova(object, ..., test, type, adjustSigma, Terms, L, verbose)
an object inheriting from class "gls"
,
representing a generalized least squares fit.
other optional fitted model objects inheriting from
classes "gls"
, "gnls"
, "lm"
, "lme"
,
"lmList"
, "nlme"
, "nlsList"
, or "nls"
.
an optional logical value controlling whether likelihood
ratio tests should be used to compare the fitted models represented
by object
and the objects in ...
. Defaults to
TRUE
.
an optional character string specifying the type of sum of
squares to be used in F-tests for the terms in the model. If
"sequential"
, the sequential sum of squares obtained by
including the terms in the order they appear in the model is used;
else, if "marginal"
, the marginal sum of squares
obtained by deleting a term from the model at a time is used. This
argument is only used when a single fitted object is passed to the
function. Partial matching of arguments is used, so only the first
character needs to be provided. Defaults to "sequential"
.
an optional logical value. If TRUE
and the
estimation method used to obtain object
was maximum
likelihood, the residual standard error is multiplied by
\(\sqrt{n_{obs}/(n_{obs} - n_{par})}\),
converting it to a REML-like estimate. This argument is only used
when a single fitted object is passed to the function. Default is
TRUE
.
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 NULL
.
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 NULL
.
an optional logical value. If TRUE
, the calling
sequences for each fitted model object are printed with the rest of
the output, being omitted if verbose = FALSE
. Defaults to
FALSE
.
a data frame inheriting from class "anova.lme"
.
Pinheiro, J. C. and Bates, D. M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York.
Likelihood comparisons are not meaningful for objects fit using restricted maximum likelihood and with different fixed effects.
gls
, gnls
, nlme
,
lme
, logLik.gls
,
AIC
, BIC
,
print.anova.lme
# AR(1) errors within each Mare
fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
correlation = corAR1(form = ~ 1 | Mare))
anova(fm1)
#> Denom. DF: 305
#> numDF F-value p-value
#> (Intercept) 1 354.7332 <.0001
#> sin(2 * pi * Time) 1 18.5034 <.0001
#> cos(2 * pi * Time) 1 1.6633 0.1981
# variance changes with a power of the absolute fitted values?
fm2 <- update(fm1, weights = varPower())
#> Error in solve.default(do.call("cbind", Xcols), apply(shifted, 2, fun, ...)): Lapack routine dgesv: system is exactly singular: U[9,9] = 0
anova(fm1, fm2)
#> Error in eval(expr, p): object 'fm2' not found
# Pinheiro and Bates, p. 251-252
fm1Orth.gls <- gls(distance ~ Sex * I(age - 11), Orthodont,
correlation = corSymm(form = ~ 1 | Subject),
weights = varIdent(form = ~ 1 | age))
#> Error in solve.default(do.call("cbind", Xcols), apply(shifted, 2, fun, ...)): Lapack routine dgesv: system is exactly singular: U[49,49] = 0
fm2Orth.gls <- update(fm1Orth.gls,
corr = corCompSymm(form = ~ 1 | Subject))
#> Error: object 'fm1Orth.gls' not found
anova(fm1Orth.gls, fm2Orth.gls)
#> Error: object 'fm1Orth.gls' not found
# Pinheiro and Bates, pp. 215-215, 255-260
#p. 215
fm1Dial.lme <-
lme(rate ~(pressure + I(pressure^2) + I(pressure^3) + I(pressure^4))*QB,
Dialyzer, ~ pressure + I(pressure^2))
#> Error in solve.default(do.call("cbind", Xcols), apply(shifted, 2, fun, ...)): Lapack routine dgesv: system is exactly singular: U[28,28] = 0
# p. 216
fm2Dial.lme <- update(fm1Dial.lme,
weights = varPower(form = ~ pressure))
#> Error: object 'fm1Dial.lme' not found
# p. 255
fm1Dial.gls <- gls(rate ~ (pressure +
I(pressure^2) + I(pressure^3) + I(pressure^4))*QB,
Dialyzer)
fm2Dial.gls <- update(fm1Dial.gls,
weights = varPower(form = ~ pressure))
anova(fm1Dial.gls, fm2Dial.gls)
#> Model df AIC BIC logLik Test L.Ratio p-value
#> fm1Dial.gls 1 11 761.1707 792.7136 -369.5853
#> fm2Dial.gls 2 12 738.2206 772.6310 -357.1103 1 vs 2 24.95006 <.0001
fm3Dial.gls <- update(fm2Dial.gls,
corr = corAR1(0.771, form = ~ 1 | Subject))
#> Error in solve.default(do.call("cbind", Xcols), apply(shifted, 2, fun, ...)): Lapack routine dgesv: system is exactly singular: U[9,9] = 0
anova(fm2Dial.gls, fm3Dial.gls)
#> Error in eval(expr, p): object 'fm3Dial.gls' not found
# anova.gls to compare a gls and an lme fit
anova(fm3Dial.gls, fm2Dial.lme, test = FALSE)
#> Error: object 'fm3Dial.gls' not found
# Pinheiro and Bates, pp. 261-266
fm1Wheat2 <- gls(yield ~ variety - 1, Wheat2)
fm3Wheat2 <- update(fm1Wheat2,
corr = corRatio(c(12.5, 0.2),
form = ~ latitude + longitude, nugget = TRUE))
#> Error in solve.default(do.call("cbind", Xcols), apply(shifted, 2, fun, ...)): Lapack routine dgesv: system is exactly singular: U[9,9] = 0
# Test a specific contrast
anova(fm3Wheat2, L = c(-1, 0, 1))
#> Error: object 'fm3Wheat2' not found