Learn R Programming

HelpersMG (version 5.1)

ExtractAIC.glm: Return AIC, AICc or BIC from a glm object

Description

For glm fits the family's aic() function is used to compute the AIC. The choice between different criteria is done by setting a global option AIC. It can be checked using show.option=TRUE. Indeed, it is not possible to use the ... parameter due to a bug in some functions of MASS package. If you want to use this function as a replacement for setpAIC(), do extractAIC.glm <- ExtractAIC.glm before.

Usage

ExtractAIC.glm(fit, scale = 0, k = 2, ...)

Arguments

fit

fitted model, the result of a fitter glm.

scale

unused for glm.

k

numeric specifying the <U+2018>weight<U+2019> of the equivalent degrees of freedom (=: edf) part in the AIC formula.

...

further arguments (currently unused because addterm.glm and dropterm.glm using this function do not transmit them).

Value

A numeric named vector of length 2, with first and second elements giving edf the <U+2018>equivalent degrees of freedom<U+2019> for the fitted model fit. x the Information Criterion for fit.

Details

ExtractAIC.glm returns AIC, AICc or BIC from a glm object

See Also

Other AIC: FormatCompareAIC(), compare_AICc(), compare_AIC(), compare_BIC()

Examples

Run this code
# NOT RUN {
extractAIC.glm <- ExtractAIC.glm
n <- 100
x <- rnorm(n, 20, 2)
A <- rnorm(n, 20, 5)
g <- glm(x ~ A)
extractAIC(g, show.option=TRUE)
options(AIC="AIC")
extractAIC(g)
options(AIC="BIC")
extractAIC(g)
options(AIC="AICc")
extractAIC(g)
# }

Run the code above in your browser using DataLab