Analysis of Deviance for Vector Generalized Linear Model Fits (2024)

anova.vglm {VGAM}R Documentation

Description

Compute an analysis of deviance table for one or morevector generalized linear model fits.

Usage

## S3 method for class 'vglm'anova(object, ..., type = c("II", "I", "III", 2, 1, 3), test = c("LRT", "none"), trydev = TRUE, silent = TRUE)

Arguments

object, ...

objects of class vglm, typicallythe result of a call to vglm, or a list ofobjects for the "vglmlist" method.Each model must have an intercept term.If "vglmlist" is used then type = 1 ortype = "I" must be specified.

type

character or numeric;any one of the(effectively three) choices given.Note that anova.glmhas 1 or "I"as its default;and that Anova.glm() in car(that is, the car package)has 2 or "II" as its default(and allows for type = "III"), soone can think of this function asa combination of anova.glmand Anova.glm() in car,but with the default of the latter.See Details below for more information.

test

a character string,(partially) matching one of"LRT" and"none".In the future it is hoped that "Rao" be also supported,to conduct score tests.The first value is the default.

trydev

logical; if TRUE then the deviance is used if possible.Note that only a few VGAM family functions have adeviance that is defined and implemented.Setting it FALSE means the log-likelihood will be used.

silent

logical; if TRUE then any warnings will be suppressed.These may arise by IRLS iterations not converging duringthe fitting of submodels.Setting it FALSE means that any warnings are given.

Details

anova.vglm is intended to be similar toanova.glmso specifying a single object and type = 1 gives asequential analysis of deviance table for that fit.By analysis of deviance, it is meant looselythat if the deviance of the model is not defined or implemented,then twice the difference between the log-likelihoods of twonested models remains asymptotically chi-squared distributedwith degrees of freedom equal to the difference in the numberof parameters of the two models.Of course, the usual regularity conditions are assumed to hold.For Type I,the analysis of deviance table hasthe reductions in the residual devianceas each term of the formula is added in turn are given in asthe 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 theeach term is added sequentially from first to last.

The Anova() function in car allows for testingType II and Type III (SAS jargon) hypothesistests, although the definitions used are not preciselythat of SAS.As car notes,Type I rarely test interesting hypotheses in unbalanceddesigns. Type III enter each term last, keeping allthe other terms in the model.

Type II tests,according to SAS,add the term after all other terms have been added to the modelexcept terms that contain the effect being tested; an effectis contained in another effect if it can be derived by deletingvariables from the latter effect.Type II tests are currently the default.

As in anova.glm, but not asAnova.glm() in car,if more than one object is specified, thenthe table has a row for theresidual degrees of freedom and deviance for each model.For all but the first model, the change in degrees of freedomand deviance is also given. (This only makes statistical senseif the models are nested.) It is conventional to list themodels from smallest to largest, but this is up to the user.It is necessary to have type = 1 with more than oneobjects are specified.

See anova.glm for more detailsand warnings.The VGAM package now implements full likelihood modelsonly, therefore no dispersion parameters are estimated.

Value

An object of class "anova" inheriting fromclass "data.frame".

Warning

See anova.glm.Several VGAM family functions implement distributionswhich do not satisfying the usual regularity conditions needed forthe LRT to work. No checking or warning is given for these.

As car says, be careful of Type III testsbecause they violate marginality.Type II tests (the default) do not have this problem.

Note

It is possible for this function to stopwhen type = 2 or 3, e.g.,anova(vglm(cans ~ myfactor, poissonff, data = boxcar))where myfactor is a factor.

The code was adapteddirectly from anova.glmand Anova.glm() in carby T. W. Yee.Hence the Type II and Type III tests do notcorrespond precisely with the SAS definition.

See Also

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.

Examples

# 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")

[Package VGAM version 1.1-11 Index]

Analysis of Deviance for Vector Generalized Linear Model Fits (2024)

References

Top Articles
Latest Posts
Article information

Author: Melvina Ondricka

Last Updated:

Views: 5815

Rating: 4.8 / 5 (48 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Melvina Ondricka

Birthday: 2000-12-23

Address: Suite 382 139 Shaniqua Locks, Paulaborough, UT 90498

Phone: +636383657021

Job: Dynamic Government Specialist

Hobby: Kite flying, Watching movies, Knitting, Model building, Reading, Wood carving, Paintball

Introduction: My name is Melvina Ondricka, I am a helpful, fancy, friendly, innocent, outstanding, courageous, thoughtful person who loves writing and wants to share my knowledge and understanding with you.