Description Usage Arguments Details Value Warning Note See Also Examples
Compute an analysis of deviance table for one or more vector generalized linear model fits.
1 2 3 
object, ... 
objects of class 
type 
character or numeric;
any one of the
(effectively three) choices given.
Note that 
test 
a character string,
(partially) matching one of

trydev 
logical; if 
silent 
logical; if 
anova.vglm
is intended to be similar to
anova.glm
so specifying a single object and type = 1
gives a
sequential analysis of deviance table for that fit.
By analysis of deviance, it is meant loosely
that if the deviance of the model is not defined or implemented,
then twice the difference between the loglikelihoods of two
nested models remains asymptotically chisquared distributed
with degrees of freedom equal to the difference in the number
of parameters of the two models.
Of course, the usual regularity conditions are assumed to hold.
For Type I,
the analysis of deviance table has
the reductions in the residual deviance
as each term of the formula is added in turn are given in as
the rows of a table, plus the residual deviances themselves.
Type I or sequential tests
(as in anova.glm
).
are computationally the easiest of the three methods.
For this, the order of the terms is important, and the
each term is added sequentially from first to last.
The Anova()
function in car allows for testing
Type II and Type III (SAS jargon) hypothesis tests,
although the definitions used are not precisely that of SAS.
As car notes,
Type I rarely test interesting hypotheses in unbalanced designs.
Type III enter each term last, keeping all the other terms in the
model.
Type II tests,
according to SAS,
add the term after all other terms have been added
to the model except terms that contain the effect being tested;
an effect is contained in another effect if it can be derived by
deleting variables from the latter effect.
Type II tests are currently the default.
As in anova.glm
, but not as
Anova.glm()
in car,
if more than one object is specified, then
the table has a row for the
residual degrees of freedom and deviance for each model.
For all but the first model, the change in degrees of freedom and
deviance is also given. (This only makes statistical sense if the
models are nested.) It is conventional to list the models from
smallest to largest, but this is up to the user.
It is necessary to have type = 1
with more than one objects
are specified.
See anova.glm
for more details
and warnings.
The VGAM package now implements full likelihood models
only, therefore no dispersion parameters are estimated.
An object of class "anova"
inheriting from
class "data.frame"
.
See anova.glm
.
Several VGAM family functions implement distributions
which do not satisfying the usual regularity conditions needed for
the LRT to work. No checking or warning is given for these.
As car says, be careful of Type III tests because they violate marginality. Type II tests (the default) do not have this problem.
It is possible for this function to stop
when type = 2
or 3
, e.g.,
anova(vglm(cans ~ myfactor, poissonff, data = boxcar))
where myfactor
is a factor.
The code was adapted
directly from anova.glm
and Anova.glm()
in car
by T. W. Yee.
Hence the Type II and Type III tests do not
correspond precisely with the SAS definition.
anova.glm
,
stat.anova
,
stats:::print.anova
,
Anova.glm()
in car if car is installed,
vglm
,
lrtest
,
add1.vglm
,
drop1.vglm
,
lrt.stat.vlm
,
score.stat.vlm
,
wald.stat.vlm
,
backPain2
,
update
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  # Example 1: a proportional odds model fitted to pneumo.
set.seed(1)
pneumo < transform(pneumo, let = log(exposure.time), x3 = runif(8))
fit1 < vglm(cbind(normal, mild, severe) ~ let , propodds, pneumo)
fit2 < vglm(cbind(normal, mild, severe) ~ let + x3, propodds, pneumo)
fit3 < vglm(cbind(normal, mild, severe) ~ let + x3, cumulative, pneumo)
anova(fit1, fit2, fit3, type = 1) # Remember to specify 'type'!!
anova(fit2)
anova(fit2, type = "I")
anova(fit2, type = "III")
# Example 2: a proportional odds model fitted to backPain2.
data("backPain2", package = "VGAM")
summary(backPain2)
fitlogit < vglm(pain ~ x2 * x3 * x4, propodds, data = backPain2)
coef(fitlogit)
anova(fitlogit)
anova(fitlogit, type = "I")
anova(fitlogit, type = "III")

Loading required package: stats4
Loading required package: splines
Analysis of Deviance Table
Model 1: cbind(normal, mild, severe) ~ let
Model 2: cbind(normal, mild, severe) ~ let + x3
Model 3: cbind(normal, mild, severe) ~ let + x3
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 13 5.0268
2 12 5.0192 1 0.00762 0.9304
3 10 4.4299 2 0.58934 0.7448
Analysis of Deviance Table (Type II tests)
Model: 'cumulative', 'VGAMordinal', 'VGAMcategorical'
Links: 'logitlink'
Response: cbind(normal, mild, severe)
Df Deviance Resid. Df Resid. Dev Pr(>Chi)
let 1 65.908 13 70.927 4.724e16 ***
x3 1 0.008 13 5.027 0.9304

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Analysis of Deviance Table (Type I tests: terms added sequentially from
first to last)
Model: 'cumulative', 'VGAMordinal', 'VGAMcategorical'
Links: 'logitlink'
Response: cbind(normal, mild, severe)
Df Deviance Resid. Df Resid. Dev Pr(>Chi)
NULL 14 101.641
let 1 96.614 13 5.027 <2e16 ***
x3 1 0.008 12 5.019 0.9304

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Analysis of Deviance Table (Type III tests: each term added last)
Model: 'cumulative', 'VGAMordinal', 'VGAMcategorical'
Links: 'logitlink'
Response: cbind(normal, mild, severe)
Df Deviance Resid. Df Resid. Dev Pr(>Chi)
let 1 65.908 13 70.927 4.724e16 ***
x3 1 0.008 13 5.027 0.9304

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
x2 x3 x4 pain
1:39 1:21 1:64 worse : 5
2:62 2:52 2:37 same :14
3:28 slight.improvement :18
moderate.improvement:20
marked.improvement :28
complete.relief :16
(Intercept):1 (Intercept):2 (Intercept):3 (Intercept):4 (Intercept):5
5.62742642 4.03372036 3.02435251 2.00848426 0.17216407
x22 x32 x33 x42 x22:x32
1.84984157 1.47577010 0.05432835 1.46663732 0.95375608
x22:x33 x22:x42 x32:x42 x33:x42 x22:x32:x42
1.46519553 1.49258460 0.53828907 0.46855766 1.86609030
x22:x33:x42
0.02565193
Analysis of Deviance Table (Type II tests)
Model: 'cumulative', 'VGAMordinal', 'VGAMcategorical'
Links: 'logitlink'
Response: pain
Df Deviance Resid. Df Resid. Dev Pr(>Chi)
x2 1 13.2238 495 329.41 0.0002764 ***
x3 2 5.1993 497 321.48 0.0743001 .
x4 1 7.5525 495 320.79 0.0059929 **
x2:x3 2 3.5567 493 315.99 0.1689175
x2:x4 1 0.6212 492 313.06 0.4306016
x3:x4 2 0.3554 493 312.79 0.8372021
x2:x3:x4 2 1.2912 491 312.44 0.5243360

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Analysis of Deviance Table (Type I tests: terms added sequentially from
first to last)
Model: 'cumulative', 'VGAMordinal', 'VGAMcategorical'
Links: 'logitlink'
Response: pain
Df Deviance Resid. Df Resid. Dev Pr(>Chi)
NULL 500 343.06
x2 1 15.9378 499 327.12 6.546e05 ***
x3 2 4.5430 497 322.58 0.10315
x4 1 6.1761 496 316.40 0.01295 *
x2:x3 2 3.1601 494 313.24 0.20597
x2:x4 1 0.4467 493 312.79 0.50390
x3:x4 2 0.3554 491 312.44 0.83720
x2:x3:x4 2 1.2912 489 311.15 0.52434

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Analysis of Deviance Table (Type III tests: each term added last)
Model: 'cumulative', 'VGAMordinal', 'VGAMcategorical'
Links: 'logitlink'
Response: pain
Df Deviance Resid. Df Resid. Dev Pr(>Chi)
x2 1 2.6030 490 313.75 0.1067
x3 2 3.7380 491 314.88 0.1543
x4 1 1.7479 490 312.89 0.1861
x2:x3 2 3.9591 491 315.11 0.1381
x2:x4 1 0.8115 490 311.96 0.3677
x3:x4 2 0.4165 491 311.56 0.8120
x2:x3:x4 2 1.2912 491 312.44 0.5243
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.