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 on April 23, 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   Steve Samuels <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: "bsample" and "set seed" together do not work!
Date   Fri, 17 Sep 2010 09:22:20 -0400

Actually, by setting the seed in the loop, you ensure that the same
sample will be drawn every time.  I doubt if this is what you
intended..  Set the seed at the beginning the program outside the
loop.



On Fri, Sep 17, 2010 at 9:15 AM, Steve Samuels <sjsamuels@gmail.com> wrote:
> Your program works for me, if I eliminate the "start" line.
>
> The FAQ ask that you show us what you typed exactly and what Stata
> said. .  If you don't show us  the results,  we can't tell what your
> mistake is.
>
> Steve
>
> On Fri, Sep 17, 2010 at 8:04 AM, Daniele Pacifico
> <danielepacifico@yahoo.it> wrote:
>> Dear Stata users,
>>
>> I am working with the command "bsample"  and I discovered that the command "set
>> seed #" stops "bsample" from drawing different samples from my data.. Here is an
>> example:
>>
>> ___start example___
>> clear all
>> set obs 1000
>> drawnorm x
>> local r=6
>>
>> forvalues i=1/`r'{
>> preserve
>>  bsample
>>  su x
>>  set seed 1234567890
>> restore
>> }
>>
>>
>> ___end example___
>>
>> 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?
>>
>> Thanks in advance for any help.
>>
>> Best,
>> Daniele
>>
>>
>>
>>
>>
>> *
>> *   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