[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: seed setting and -simulate-

From   "Carlo Lazzaro" <[email protected]>
To   <[email protected]>
Subject   st: seed setting and -simulate-
Date   Sun, 20 Jan 2008 13:33:58 +0100

Dear Statalisters,
I have a question concerning seed setting before -simulate-.

My question came up after a comparison between the results of 

set obs 10000

gen A=556 in 1/10000

. sum A

    Variable |       Obs        Mean    Std. Dev.       Min        Max
           A |     10000         556           0        556        556

. return list

                 r(N) =  10000
             r(sum_w) =  10000
              r(mean) =  556
               r(Var) =  0
                r(sd) =  0
               r(min) =  556
               r(max) =  556
               r(sum) =  5560000

. scalar a=(r(mean)/r(mean))^2 //assuming that the mean is the same value as
the std. dev.

. scalar b=(r(mean)^2/r(mean)) //assuming that the mean is the same value as
the std. dev.

. simulate (b*invgammap(a, uniform())), reps(10000) nodots seed(999): sum A

      command:  summarize A
       _sim_1:  b*invgammap(a, uniform()).


gen B=649 // following the same procedure as detailed above for variable A.


-when I set -seed (999) - in -simulate- command, the results for _sim_B are
10,0000 out of 10,0000 times > _sim_A;

- when I did not specify -seed- in -simulate- command, the results for
_sim_B are 5418 out of 10,0000 times > _sim_A (and this is was I expected on
the grounds of my previous experience).

Is there any explanation supporting this (seemingly odd) difference?

Thanks a lot for your kindness and for your time.

Enjoy your Sunday and Kind Regards,


-----Messaggio originale-----
Da: [email protected]
[mailto:[email protected]] Per conto di Maarten buis
Inviato: sabato 19 gennaio 2008 16.25
A: [email protected]
Oggetto: Re: st: Monte Carlo resampling

--- Carlo Lazzaro <[email protected]> wrote:
> does -simulate- suite resample with reintroduction?

No, -simulate- just repeatedly calls a program and stores the results.
So, the way you sample (or whether you sample at all) depends on the
program that -simulate- calls. If your program drew a sample with
reintroduction than -simulate- would do what you just asked. However,
the easier way to do that is to call -bootstrap-.

The strong point of -simulate- is that is makes it easier to play
around with different techniques and find out their strong and weak
points. Its primary usefullness is in that sense theoretical, while the
primary usefulness of -bootstrap- is empirical (it helps you to
describe your data). Though the distinction is not black and white. 

Some examples of the use of -simulate- are: 
(bottom of the post)
though note:

Hope this helps,

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Sent from Yahoo! Mail - a smarter inbox

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index