-swor- was published in STB-59.
I would have sworn that you don't
now need it for your purpose,
as -sample- has since been modified
to support a -count- option.
However, I cannot reproduce your problem.
I can get -swor- to select the same sample
again and again.
. forval i = 1/10 {
2. qui sysuse auto, clear
3. set seed 28031952
4. qui swor 1, gen(select) by(foreign)
5. levels make, clean
6. }
Buick Riviera VW Rabbit
Buick Riviera VW Rabbit
Buick Riviera VW Rabbit
Buick Riviera VW Rabbit
Buick Riviera VW Rabbit
Buick Riviera VW Rabbit
Buick Riviera VW Rabbit
Buick Riviera VW Rabbit
Buick Riviera VW Rabbit
Buick Riviera VW Rabbit
Try as I can, the Rabbit keeps coming
out of the hat.
Nick
[email protected]
Gabriel Demombynes wrote
I'm using the user-written command swor to draw random
samples with
replacement. I've discovered that even when I've set
the seed, the
command does not always draw the same samples in
repeated runs when
using by. It does not have this problem when not using
by.
When I do the following, I get different results each
time I run the
program:
set seed 6662
use alldata, clear
swor 1, gen(select) by(sex)
li
The problem seems to be particular to the variables in
my dataset.
When I create a new group variable, e.g. assigning
group=1 for the
first half of the observations, and group=2 for the
second half, and
then run the analysis by(group) there's no problem; I
can reproduce the same results on multiple draws.
But the problem
persists even when I create a new group variable based
on a pre-
existing variable and use that, e.g.
set seed 6662
use alldata, clear
gen group=1 if sex==1
replace group=2 if sex==2
swor 1, gen(select) by(group)
li
I've looked at the swor ado file, but I can't figure
out what might be wrong. Any suggestions?
*
* 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/