Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Re: Random draws from a negative binomial distribution

From   Dirk Enzmann <>
Subject   Re: st: Re: Random draws from a negative binomial distribution
Date   Thu, 20 Jun 2013 11:46:48 +0200

Thanks to Andrew, Kieran and Timothy for their helpful comments and to StataCorp for solving this problem so quickly!

Kieran showed a workaround to the -rpoisson- limit that may work for rough estimates and Timothy provided a very useful link to details on programming the simulation of Poisson variables.

StataCorp and the Stata community are really amazing!


At Wed, 19 Jun 2013 15:33:56 -0500, (Richard Gates, StataCorp) wrote:
Dirk Enzmann has tickled a domain limit of Stata's -rnbinomial()- function.

He states:

>  Unfortunately, I am not able to solve the following problem in Stata
>  which I can solve easily using R:
>  As far as I can see Stata does not allow to draw random values from a
>  negative binomial distribution if "size" (= 1/alpha) is less than 0.1
>  (see -h rnbinomial-). I tried to circumvent this problem by (1) creating
>  random draws from a gamma distribution with shape parameter = size and
>  scale parameter = (1-prob)/prob, with prob = size/(size+mu), and
>  subsequently creating random draws from a poisson distribution with
>  parameter m = the result of the previous random draws from the gamma
>  distribution. However, if size is small, this does not help either.
We have determined that the domain limit for the size parameter, labeled as n
in Stata's documentation, is too conservative for a certain region of the
parameter space, when n<0.1 but n*(1-p)/p<100 and p^n>1e-4.  Dirk's example
falls into this region.  We will update -rnbinomial()- in Stata 12 and Stata
13 to produce a result in this region.

- -- Rich

Dr. Dirk Enzmann
Institute of Criminal Sciences
Dept. of Criminology
Rothenbaumchaussee 33
D-20148 Hamburg

phone: +49-(0)40-42838.7498 (office)
       +49-(0)40-42838.4591 (Mrs Billon)
fax:   +49-(0)40-42838.2344
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index