[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: set seed and gsample
I say No to your No.
Shige's question was
"I want to make sure I get the same sample each time
I invoke the gsample command".
. set obs 100
obs was 0, now 100
. gen i = _n
. set seed 280352
. gsample 20 , generate(sample1)
. gsample 20 , generate(sample2)
. assert sample1 == sample2
31 contradictions in 100 observations
assertion is false
. set seed 280352
. gsample 20 , generate(sample3)
. assert sample1 == sample3
<NB: no response>
Perhaps Shige did not mean what he said, or
I am quoting out of context, but
but that quoted text was I what responding to.
> Some days ago, the following issue concerning -gsample- was posted by
> Shige on behalf of a colleague:
> > I am trying to draw a PPS sample using the "gsample"
> command. I want
> > to make sure I get the same sample each time I invoke the gsample
> > command by using the "set seed" command. However, even
> after I set the
> > random seed using "set seed" command, I still get different sample
> > each time. Has anybody encountered this problem?
> Inspection of Shige's colleague's do-file revealed that some -sort-
> and -bysort- commands were causing the trouble. It had nothing to do
> with -gsample-. -sort- has its own random number generator to break
> ties that does not depend on -set seed-. To make -sort- stable either
> specify the -stable- option or, better, add a -set sortseed- command
> at the beginning of the script (see -help sortseed-).
> Nick wrote:
> > You must -set seed- immediately before calling -gsample-.
> No. The seed should be set somewhere in the beginning of the do-file,
> before any command that might possibly depend on it (and it should
> only be set once - do not set the seed repeatedly in one script).
* For searches and help try: