\HeaderA{extractAIC}{Extract AIC from a Fitted Model}{extractAIC}
\keyword{models}{extractAIC}
\begin{Description}\relax
Computes the (generalized) Akaike \bold{A}n \bold{I}nformation
\bold{C}riterion for a fitted parametric model.
\end{Description}
\begin{Usage}
\begin{verbatim}
extractAIC(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{\LinkA{lm}{lm}}.
\item[\code{scale}] optional numeric specifying the scale parameter of the
model, see \code{scale} in \code{\LinkA{step}{step}}.

\item[\code{k}] numeric specifying the \dQuote{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
This is a generic function, with methods in base \R{} for \code{"aov"},
\code{"coxph"}, \code{"glm"}, \code{"lm"}, \code{"negbin"}
and \code{"survreg"} classes.

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 linear models with unknown scale (i.e., for \code{\LinkA{lm}{lm}} and
\code{\LinkA{aov}{aov}}), \eqn{-2\log L}{} is computed from the
\emph{deviance} and uses a different additive constant to \code{\LinkA{AIC}{AIC}}.

\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{\LinkA{step}{step}}.
\end{Details}
\begin{Value}
A numeric vector of length 2, giving

\begin{ldescription}
\item[\code{edf}] the \dQuote{\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{\LinkA{add1}{add1}},
\code{\LinkA{drop1}{drop1}} and \code{\LinkA{step}{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. (2002)
\emph{Modern Applied Statistics with S.}
New York: Springer (4th ed).
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{AIC}{AIC}}, \code{\LinkA{deviance}{deviance}}, \code{\LinkA{add1}{add1}},
\code{\LinkA{step}{step}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
example(glm)
extractAIC(glm.D93)#>>  5  15.129
\end{ExampleCode}
\end{Examples}

