anova2 | R Documentation |
Allows to compare nested generalized linear models using Wald, score, gradient, and likelihood ratio tests.
anova2(
object,
...,
test = c("wald", "lr", "score", "gradient"),
verbose = TRUE
)
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 ("lr") tests. As default, |
verbose |
an (optional) logical indicating if should the report of results be printed. As default, |
The Wald, Rao's score and Terrell's gradient tests are performed using the expected Fisher information matrix.
A matrix with three columns which contains the following:
Chi
The value of the statistic of the test.
Df
The number of degrees of freedom.
Pr(>Chi)
The p-value of the test computed using the Chi-square distribution.
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.
## 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="lr")
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="lr")
anova2(fit1, fit2, test="score")
anova2(fit1, fit2, test="wald")
anova2(fit1, fit2, test="gradient")
## Example 3
data(aucuba)
fit <- glm(lesions ~ 1 + time, family=poisson("log"), data=aucuba)
anova2(fit, test="lr")
anova2(fit, test="score")
anova2(fit, test="wald")
anova2(fit, test="gradient")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.