extractAIC {stats} | R Documentation |
Computes the (generalized) Akaike An Information Criterion for a fitted parametric model.
extractAIC(fit, scale, k = 2, ...)
fit |
fitted model, usually the result of a fitter like
|
scale |
optional numeric specifying the scale parameter of the
model, see |
k |
numeric specifying the ‘weight’ of the
equivalent degrees of freedom ( |
... |
further arguments (currently unused in base R). |
This is a generic function, with methods in base R for "aov"
,
"coxph"
, "glm"
, "lm"
, "negbin"
and "survreg"
classes.
The criterion used is
AIC = - 2\log L + k \times \mbox{edf},
where L
is the likelihood and edf
the equivalent degrees
of freedom (i.e., the number of free parameters for usual parametric
models) of fit
.
For linear models with unknown scale (i.e., for lm
and
aov
), -2\log L
is computed from the
deviance and uses a different additive constant to
logLik
and hence AIC
. If RSS
denotes the (weighted) residual sum of squares then extractAIC
uses for - 2\log L
the formulae RSS/s - n
(corresponding
to Mallows' C_p
) in the case of known scale s
and
n \log (RSS/n)
for unknown scale. AIC
only handles
unknown scale and uses the formula
n \log (RSS/n) - n + n \log 2\pi - \sum \log w
where w
are the weights.
For glm
fits the family's aic()
function to compute the
AIC: see the note under logLik
about the assumptions this makes.
k = 2
corresponds to the traditional AIC, using k =
log(n)
provides the BIC (Bayesian IC) instead.
A numeric vector of length 2, giving
edf |
the ‘equivalent degrees of freedom’
for the fitted model |
AIC |
the (generalized) Akaike Information Criterion for |
This function is used in add1
, drop1
and step
and similar functions in package MASS
from which it was adopted.
B. D. Ripley
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. New York: Springer (4th ed).
AIC
, deviance
, add1
,
step
utils::example(glm)
extractAIC(glm.D93)#>> 5 15.129