Bookmark and Share

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


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

SV: st: random number generator for gamma


From   "Tomas Lind" <[email protected]>
To   <[email protected]>
Subject   SV: st: random number generator for gamma
Date   Fri, 1 Oct 2010 08:34:24 +0200

Thank you very much Scott Merryman for your kind answer.

Best,
Tomas



-----Ursprungligt meddelande-----
Från: [email protected]
[mailto:[email protected]] För Scott Merryman
Skickat: den 29 september 2010 17:25
Till: [email protected]
Ämne: Re: st: random number generator for gamma

The mean of a gamma distribution  = shape*scale.

In the rndgamx syntax the scale is calculated as mu*shape.

With m=2  -rndgamx  m , s(11.11)- should produce of mean of 22.22*11.11 =
246.86

If you want a mean of 2 with a shape parameter of 11.11 then mu =
2/(11.11)^2 :

. clear

. set obs 10000
obs was 0, now 10000

. gen y = 2/(11.11)^2

. rndgamx  y  , s(11.11)
( Generating ............ )
Variable xg created.

. sum

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
           y |     10000    .0162032           0   .0162032   .0162032
          xg |     10000    2.001865    .5960008     .40838   4.753399


Scott

On Wed, Sep 29, 2010 at 7:48 AM, Tomas Lind <[email protected]> wrote:
> Dear Statalist
>
> I?ve been using the -rnd- ado-package from Hilbe/Linde-Zwirble (update
from
> STB-28: sg44).
>
> The following syntax produces sensible results (mean and sd) when I
generate
> 20000 Gamma distributed random numbers with shape=11.11 and scale=0.18
>
> clear *
> rndgam 20000 11.11  0.18
> summarize xg    // mean=2.0 sd=0.60
>
>
>
> However, with -rndgamx- I don?t get the same values. I have probably
missed
> something fundamental. Someone know what goes on?
>
> clear *
> set obs 20000
> gen m=2         // mean=2
> rndgamx  m , s(11.11)
> summarize xg    // mean=247 sd=74
>
>
> /Tomas

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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