# Re: [R] Negative Binomial: Simulation

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Sat 15 Jul 2006 - 00:21:19 EST

On Fri, 14 Jul 2006, Hadassa Brunschwig wrote:

>
> The problem basically arises also when I want to calculate (plot) the
> cumulative distribution of the negative binomial with the calculated
> parameters mu and theta!
>
> On 7/14/06, Hadassa Brunschwig <dassybr@gmail.com> wrote:
> > Hi R-Users!
> >
> > (sorry about the last email)
> > I fitted a negative binomial distribution to my count data using the
> > function glm.nb() and obtained the calculated parameters
> > theta (dispersion) and mu.
> >
> > I would like to simulate values from this negative binomial distribution.
> > Looking at the function rnbinom() I was looking at the relationship
> > between the two possible parametrizations of the negative binomial and found
> > that for this fuction I must use:
> >
> > prob = theta/(theta+mu) and size = theta
> >
> > Theta, however, is not an integer. So how can size (which is the number of
> > successes) equal theta?

>From ?rnegbin

size: target for number of successful trials, or dispersion

```          parameter (the shape parameter of the gamma mixing
distribution). Must be strictly positive.

```

> > I know there is a function rnegbin which does what I want. I would still
> > like to raise the above question (probably a more statistical one
> > than R).
> >
> > Thanks a lot for any comments.
> >

It does seem to be a question of following the posting guide.

```--
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help