\Header{glm.nb}{Fit a Negative Binomial Generalized Linear Model}
\alias{family.negbin}{glm.nb}
\alias{logLik.negbin}{glm.nb}
\keyword{regression}{glm.nb}
\keyword{models}{glm.nb}
\begin{Description}\relax
A modification of the system function \code{\Link{glm}()} to include
estimation of the additional parameter, \code{theta}, for a
Negative Binomial generalized linear model.
\end{Description}
\begin{Usage}
\begin{verbatim}
glm.nb(formula, ...,  init.theta, link = log)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{formula}] Model formula, as for \code{glm()}.

\item[\code{...}] Any other arguments for the \code{\Link{glm}()} function except \code{family}
and, in \R, \code{offset} (but \code{\Link{offset}} can be used).

\item[\code{init.theta}] Optional initial value for the theta parameter.  If omitted a moment
estimator after an initial fit using a Poisson GLM is used.

\item[\code{link}] The link function.  Currently must be one of \code{log}, \code{sqrt}
or \code{identity}.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
An alternating iteration process is used.  For given \code{theta} the GLM
is fitted using the same process as used by \code{glm()}.  For fixed means
the \code{theta} parameter is estimated using score and information
iterations.  The two are alternated until convergence of both. (The
number of alternations and the number of iterations when estimating
\code{theta} are controlled by the \code{maxit} parameter of
\code{glm.control}.)

Setting \code{trace > 0} traces the alternating iteration
process. Setting \code{trace > 1} traces the \code{glm} fit, and
setting \code{trace > 2} traces the estimation of \code{theta}.
\end{Details}
\begin{Value}
A fitted model object of class \code{negbin} inheriting from \code{glm}
and \code{lm}.  The object is like the output of \code{glm} but contains
three additional components, namely \code{theta} for the ML estimate of
theta, \code{SE.theta} for its approximate standard error (using
observed rather than expected information), and \code{twologlik} for
twice the log-likelihood function.
\end{Value}
\begin{References}\relax
Venables, W. N. and Ripley, B. D. (2002)
\emph{Modern Applied Statistics with S.} Fourth edition.  Springer.
\end{References}
\begin{SeeAlso}\relax
\code{\Link{glm}}, \code{\Link{negative.binomial}},
\code{\Link{anova.negbin}}, \code{\Link{summary.negbin}},
\code{\Link{theta.ml}}, \code{\Link{theta.md}}, \code{\Link{theta.mm}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
quine.nb1 <- glm.nb(Days ~ Sex/(Age + Eth*Lrn), data = quine)
quine.nb2 <- update(quine.nb1, . ~ . + Sex:Age:Lrn)
quine.nb3 <- update(quine.nb2, Days ~ .^4)
anova(quine.nb1, quine.nb2, quine.nb3)
\end{ExampleCode}
\end{Examples}

