\HeaderA{theta.md}{Estimate theta of the Negative Binomial}{theta.md}
\aliasA{theta.ml}{theta.md}{theta.ml}
\aliasA{theta.mm}{theta.md}{theta.mm}
\keyword{models}{theta.md}
\begin{Description}\relax
Given the estimated mean vector, estimate \code{theta} of the
Negative Binomial Distribution.
\end{Description}
\begin{Usage}
\begin{verbatim}
theta.md(y, mu, dfr, limit = 20, eps = .Machine$double.eps^0.25)

theta.ml(y, mu, n, limit = 10, eps = .Machine$double.eps^0.25,
         trace = FALSE)

theta.mm(y, mu, dfr, limit = 10, eps = .Machine$double.eps^0.25)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{y}] Vector of observed values from the Negative Binomial.

\item[\code{mu}] Estimated mean vector.

\item[\code{n}] Number of data points (defaults to length of \code{y})

\item[\code{dfr}] Residual degrees of freedom (assuming \code{theta} known).

\item[\code{limit}] Limit on the number of iterations.

\item[\code{eps}] Tolerance to determine convergence.

\item[\code{trace}] logical: should iteration progress be printed?

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{theta.md} estimates by equating the deviance to the residual
degrees of freedom, an analogue of a moment estimator.

\code{theta.ml} uses maximum likelihood.

\code{theta.mm} calculates the moment estimator of \code{theta} by
equating the Pearson chi-square
\eqn{sum((y-\mu)^2/(\mu+\mu^2/\theta))}{} to the residual
degrees of freedom.
\end{Details}
\begin{Value}
The required estimate of \code{theta}, as a scalar.
For \code{theta.ml}, the standard error is given as attribute \code{"SE"}.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{glm.nb}{glm.nb}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
quine.nb <- glm.nb(Days ~ .^2, data = quine)
theta.md(quine$Days, fitted(quine.nb), dfr = df.residual(quine.nb))
theta.ml(quine$Days, fitted(quine.nb))
theta.mm(quine$Days, fitted(quine.nb), dfr = df.residual(quine.nb))
\end{ExampleCode}
\end{Examples}

