Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: "bsample" and "set seed" together do not work!


From   Daniele Pacifico <danielepacifico@yahoo.it>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: "bsample" and "set seed" together do not work!
Date   Fri, 17 Sep 2010 14:15:13 +0000 (GMT)

Dear Maarten,
thanks for your help. 
Well, I actually need to set the seed inside my program.. In your opinion, is 
there a way to create a "temporary seed" within a ado file? I mean, something 
like a temporary variable that disappears once the program ends?

Thanks again for your help,
Daniele



----- Original Message ----
From: Maarten buis <maartenbuis@yahoo.co.uk>
To: statalist@hsphsun2.harvard.edu
Sent: Fri, 17 September, 2010 14:48:09
Subject: Re: st: "bsample" and "set seed" together do not work!

--- On Fri, 17/9/10, Daniele Pacifico wrote:
> I am working with the command "bsample"  and I
> discovered that the command "set seed #" stops 
> "bsample" from drawing different samples from
> my data.
>
> I had this problem because I am writing an ado file that
> sets a seed when it runs.. However, I discovered that the 
> seed I define within my ado file creates the problem I
> have shown you above (i.e. I cannot use bsample with the 
> command defined in my ado file).. Do you have any advise
> about it? How can I "unset" the seed so as to allow it to
> vary randomly again with bsample?

"Do not work" does not describe your situation very well: All 
programs work exactly as they should, i.e. they do what you 
told them to do (they may not do what you want them to do, 
but that is a different question).

You might be tempted to set the seed "randomly" inside your
loop before each -bsample- command, but that does not work 
well as Bill discussed here:
http://www.stata.com/statalist/archive/2010-08/msg00834.html

I just would avoid setting the seed inside a program. In 
general it sounds like bad practice to me. For one thing
you are this way overwriting any -set seed- commands your
user might issue before your command, thus leaving them
puzzled e.g. when they are trying to run a simulation using 
your command.

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index