Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: inconsistent random numbers even using -set seed-


From   Phil Schumm <[email protected]>
To   Statalist Statalist <[email protected]>
Subject   Re: st: inconsistent random numbers even using -set seed-
Date   Thu, 30 Jan 2014 13:24:57 -0600

On Jan 30, 2014, at 12:51 PM, Seed, Paul <[email protected]> wrote:
> Thank you to Daniel Klein and Maarten L. Buis for their very helpful comments on my problem.
> I'd like to think that -sort, stable- solves the problem; but I wonder how stable it really is.
> Will I get the same results if I 
> 	a) exit Stata and then re-start it?
> 	b) change the sort order of the original data?
> 	c) change the contents of variables 
> 	d) add or delete variables?
> I am fairly certain that it will not be stable if I add or delete records.
> 
> I think for the future (if I ever need it), I will make sure there is a unique identifier 
> and sort by that, before setting the seed & invoking random variables.


This has been discussed many times before, e.g.,

    http://www.stata.com/statalist/archive/2005-09/msg00582.html

The best way to avoid being bitten by this issue is to use -isid, sort- instead of -sort- any time you need to ensure that the order of the dataset is uniquely determined (i.e., any time you are doing a calculation/manipulation that depends on the order of the dataset).  Using -sort, stable- doesn't help here -- it just pushes the problem upstream.


-- Phil


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index