\Header{extractAIC}{Extract AIC from a Fitted Model}
\methalias{extractAIC.aov}{extractAIC}
\methalias{extractAIC.coxph}{extractAIC}
\methalias{extractAIC.glm}{extractAIC}
\methalias{extractAIC.lm}{extractAIC}
\methalias{extractAIC.negbin}{extractAIC}
\methalias{extractAIC.survreg}{extractAIC}
\keyword{models}{extractAIC}
\begin{Description}\relax
Computes the (generalized) \bold{A}kaike \bold{I}nformation
\bold{C}riterion for a fitted parametric model.\end{Description}
\begin{Usage}
\begin{verbatim}
extractAIC    (fit, scale,     k = 2, ...)  
extractAIC.lm (fit, scale = 0, k = 2, ...)
extractAIC.glm(fit, scale = 0, k = 2, ...)  
extractAIC.aov(fit, scale = 0, k = 2, ...)  
extractAIC.coxph  (fit, scale, k = 2, ...)  
extractAIC.negbin (fit, scale, k = 2, ...)  
extractAIC.survreg(fit, scale, k = 2, ...)  
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{fit}] fitted model, usually the result of a fitter like
\code{\Link{lm}}.
\item[\code{scale}] optional numeric specifying the scale parameter of the
model, see \code{scale} in \code{\Link{step}}.

\item[\code{k}] numeric specifying the ``weight'' of the
\emph{equivalent degrees of freedom} (\eqn{\equiv}{=:}\code{edf})
part in the AIC formula.
\item[\code{...}] further arguments (currently unused in base \R).
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The criterion used is 
\deqn{AIC = - 2\log L +  k \times \mbox{edf},}{AIC = - 2*log L +  k * edf,}
where \eqn{L}{} is the likelihood
and \code{edf} the equivalent degrees of freedom (i.e., the number of
parameters for usual parametric models) of \code{fit}.

For generalized linear models (i.e., for \code{\Link{lm}},
\code{\Link{aov}}, and \code{\Link{glm}}), \eqn{-2\log L}{} is
the \emph{deviance}, as computed by \code{\Link{deviance}(fit)}, plus
a constant.

\code{k = 2} corresponds to the traditional AIC, using \code{k =
    log(n)} provides the BIC (Bayes IC) instead.

For further information, particularly about \code{scale}, see
\code{\Link{step}}.\end{Details}
\begin{Value}
A numeric vector of length 2, giving
\begin{ldescription}
\item[\code{edf}] the ``\bold{e}quivalent \bold{d}egrees of \bold{f}reedom''
of the fitted model \code{fit}.
\item[\code{AIC}] the (generalized) Akaike Information Criterion for \code{fit}.
\end{ldescription}
\end{Value}
\begin{Note}\relax
These functions are used in \code{\Link{add1}},
\code{\Link{drop1}} and \code{\Link{step}} and that may be their
main use.\end{Note}
\begin{Author}\relax
B. D. Ripley\end{Author}
\begin{References}\relax
Venables, W. N. and Ripley, B. D. (1997)
\emph{Modern Applied Statistics with S-PLUS.}
New York: Springer (2nd ed).\end{References}
\begin{SeeAlso}\relax
\code{\Link{deviance}}, \code{\Link{add1}}, \code{\Link{step}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
example(glm)
extractAIC(glm.D93)#>>  5  15.129
\end{ExampleCode}
\end{Examples}

