anova2: Comparison of nested Generalized Linear Models

Description Usage Arguments Details Value References Examples

View source: R/glms.R

Description

Allows to compare nested generalized linear models using Wald, score, gradient, and likelihood ratio tests.

Usage

1
2
3
4
5
6
anova2(
  object,
  ...,
  test = c("wald", "lrt", "score", "gradient"),
  verbose = TRUE
)

Arguments

object

an object of the class glm which is obtained from the fit of a generalized linear model.

...

another objects of the class glm which are obtained from the fit of generalized linear models.

test

an (optional) character string indicating the required type of test. The available options are: Wald ("wald"), Rao's score ("score"), Terrell's gradient ("gradient"), and likelihood ratio ("lrt") tests. By default, test is set to be "wald".

verbose

an (optional) logical indicating if should the report of results be printed. By default, verbose is set to be TRUE.

Details

The Wald, Rao's score and Terrell's gradient tests are performed using the expected Fisher information matrix.

Value

A matrix with three columns which contains the following:

References

Buse A. (1982) The Likelihood Ratio, Wald, and Lagrange Multiplier Tests: An Expository Note. The American Statistician 36, 153-157.

Terrell G.R. (2002) The gradient statistic. Computing Science and Statistics 34, 206 – 215.

Examples

 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
## Example 1
Auto <- ISLR::Auto
fit1 <- glm(mpg ~ weight, family=inverse.gaussian("log"), data=Auto)
fit2 <- update(fit1, . ~ . + horsepower)
fit3 <- update(fit2, . ~ . + horsepower:weight)
anova2(fit1, fit2, fit3, test="lrt")
anova2(fit1, fit2, fit3, test="score")
anova2(fit1, fit2, fit3, test="wald")
anova2(fit1, fit2, fit3, test="gradient")

## Example 2
burn1000 <- aplore3::burn1000
mod <- death ~ age + tbsa + inh_inj
fit1 <- glm(mod, family=binomial("logit"), data=burn1000)
fit2 <- update(fit1, . ~ . + inh_inj + age*inh_inj + tbsa*inh_inj)
anova2(fit1, fit2, test="lrt")
anova2(fit1, fit2, test="score")
anova2(fit1, fit2, test="wald")
anova2(fit1, fit2, test="gradient")

## Example 3
fit <- glm(lesions ~ 1 + time, family=poisson("log"), data=aucuba)
anova2(fit, test="lrt")
anova2(fit, test="score")
anova2(fit, test="wald")
anova2(fit, test="gradient")

glmtoolbox documentation built on June 9, 2021, 9:07 a.m.