Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: seed command with rndbin


From   Roger Harbord <[email protected]>
To   [email protected]
Subject   Re: st: seed command with rndbin
Date   Tue, 12 Aug 2003 15:36:32 +0100

--On 12 August 2003 15:07 +0100 "Allardice, Gwen" <[email protected]> wrote:


I have recently found a problem in  stata v7 . I have been using the
rndbin program extensively in some simulations I am running.

I would like to be able to replicate  my results and find that the seed
command does not seem to work; I keep getting different results.

e.g. a simple example should illustrate my problem. the following three
lines of stata will generate and show me an appropriate random number but
repeating the three commands then gives me a different number. I want it
to give me the same number.



set seed 2
rndbin 1 0.33  6
display   xb

Can someone show me how to run the rndin command more than once and get
the same result each time.

Thanks for pointing this out, I'd just assumed I was getting reproducible pseudorandom numbers when in fact I wasn't - i hadn't thought to check!

If you check the start of the code for -rndbin-, you'll find it's written in version 3.1.

If you check the help page for -version- and search for "seed" you'll find this:

If you set version to 3.1 or less, the following will be true
1. uniform() refers to the old random-number generator
2. set seed sets the old random-number seed


The solution is now simple:

version 3.1: set seed 2
rndbin 1 0.33 6
display xb

- gives the same each time. Unfortunately you can't replicate results you've already got..

Roger.
----------------------------------------------------
Roger Harbord mailto:[email protected]
Department of Social Medicine, University of Bristol

*
* 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/




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