extractAIC
Extract AIC from a Fitted Model

Description

Extract AIC from a Fitted Model.

Usage

extractAIC(fit, scale, k = 2, ...)
## S3 method for class 'glm':
extractAIC(fit, scale = 0, k = 2, ...) 
## S3 method for class 'lm':
extractAIC(fit, scale = 0, k = 2, ...) 




Arguments

fit object inheriting from fitted model or class.
scale a numeric number, indicates the scale of deviance for linear model.
k a numeric number, the coefficient for residual degrees of freedom.
... additional arguments to be pass to future functions.

Details

These are generic functions of classes "glm", "lm", "coxph", "aov", "negbin", and "survreg" to calculate equivalent degree of freedom and AIC value.
The AIC value is calculated using the formula -2 * log-likelihood + k * edf. where edf is the equivalent degrees of freedom. For linear models (aov and lm), -2*log-likelihood value is computed by n * log(RSS/n) where RSS is the deviance for the linear model. If scale is greater than 0, -2*log-likelihood is computed by RSS/scale - n.
Value
a vector with the equivalent degrees of freedom and the AIC value.
References
Venables, W. N. and Ripley, B. D. 2002. Modern Applied Statistics with S. Fourth Edition. New York, NY: Springer.
See Also
AIC, df.residual
Examples
ldose <- rep(0:5, 2)
numdead <- c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)
sex <- factor(rep(c("M", "F"), c(6, 6)))
SF <- cbind(numdead, numalive = 20 - numdead)
budworm.lg <- glm(SF ~ sex*ldose, family = binomial)
extractAIC(budworm.lg)

lm.fit <- lm(y ~ ., data=Sdatasets::freeny) extractAIC(lm.fit)

P <- ordered(rep(1:3, rep(3,3))) N <- ordered(rep(1:3,3)) Plants <- c(449, 413, 326, 409, 358, 291, 341, 278, 312) Plants <- Plants/12 fit.df <- data.frame(Plants, P, N) fit.aov <- aov(Plants ~ N * P, data = fit.df, weights = rep(12,9), qr = TRUE) extractAIC(fit.aov)

Package stats version 6.1.1-7
Package Index