# 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

scalars:
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()).

and

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

However:

-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?

Enjoy your Sunday and Kind Regards,

Carlo

-----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:
http://www.stata.com/statalist/archive/2007-12/msg00504.html
(bottom of the post)

http://www.stata.com/statalist/archive/2007-09/msg00638.html
http://www.stata.com/statalist/archive/2007-09/msg00665.html

http://lists.utsouthwestern.edu/pipermail/impute/2008-January/000530.html
though note:
http://lists.utsouthwestern.edu/pipermail/impute/2008-January/000531.html

Hope this helps,
Maarten

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

Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

__________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```