\Header{extractAIC}{Extract AIC from a Fitted Model}
\alias{extractAIC.aov}{extractAIC}
\alias{extractAIC.lm}{extractAIC}
\alias{extractAIC.glm}{extractAIC}
\alias{extractAIC.coxph}{extractAIC}
\alias{extractAIC.negbin}{extractAIC}
\alias{extractAIC.survreg}{extractAIC}
\keyword{models}{extractAIC}
\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[\texttt{fit}] fitted model, usually the result of a fitter like \texttt{\Link{lm}}.
\item[\texttt{scale}] optional numeric specifying the scale parameter of the
model, see \texttt{scale} in \texttt{\Link{step}}.

\item[\texttt{k}] numeric specifying the ``weight'' of the
\emph{equivalent degrees of freedom} (\eqn{\equiv}{=:}\texttt{edf})
part in the AIC formula.
\item[\texttt{...}] further arguments (currently unused in base \R).
\end{ldescription}
\end{Arguments}
\begin{Description}
Computes the (generalized) \bold{A}kaike \bold{I}nformation
\bold{C}riterion for \texttt{fit}, i.e.
\deqn{AIC = - 2\log L +  k \times \mbox{edf},}{AIC = - 2*log L +  k * edf,}
where \eqn{L}{} is the likelihood
and \texttt{edf} the equivalent degrees of freedom (i.e., the number of
parameters for usual parametric models) of \texttt{fit}.\end{Description}
\begin{Details}
For generalized linear models (i.e., for \texttt{\Link{lm}},
\texttt{\Link{aov}}, and \texttt{\Link{glm}}), \eqn{-2\log L}{} is
the \emph{deviance}, as computed by \texttt{\Link{deviance}(fit)}.

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

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

