\Header{rnegbin}{Simulate Negative Binomial Variates}
\keyword{distribution}{rnegbin}
\begin{Description}\relax
Function to generate random outcomes from a Negative Binomial distribution,
with mean \code{mu} and variance \code{mu + mu\textasciicircum{}2/theta}.
\end{Description}
\begin{Usage}
\begin{verbatim}
rnegbin(n, mu = n, theta = stop("theta must be given"))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{n}] If a scalar, the number of sample values required.  If a vector,
\code{length(n)} is the number required and \code{n} is used as the mean vector if
\code{mu} is not specified.

\item[\code{mu}] The vector of means.  Short vectors are recycled.

\item[\code{theta}] Vector of values of the \code{theta} parameter.  Short vectors are recycled.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The function uses the representation of the Negative Binomial distribution
as a continuous mixture of Poisson distributions with Gamma distributed means.
Unlike \code{rnbinom} the index can be arbitrary.
\end{Details}
\begin{Value}
Vector of random Negative Binomial variate values.
\end{Value}
\begin{Section}{Side Effects}
Changes \code{.Random.seed} in the usual way.
\end{Section}
\begin{Examples}
\begin{ExampleCode}
# Negative Binomials with means fitted(fm) and theta = 4.5
fm <- glm.nb(Days ~ ., data = quine)
dummy <- rnegbin(fitted(fm), theta = 4.5)
\end{ExampleCode}
\end{Examples}

