Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Running the same do file but getting different results


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Running the same do file but getting different results
Date   Sat, 9 Feb 2008 20:32:09 +0000 (GMT)

You would get different results each time you run a do-file if your
do-file does something random, e.g. -bootstrap- creates random draws
from your data. From your description I guess that you are doing mostly
data preparation. The only randomness I can think of in that situation
is sorting. When observations are sorted the order of the observations
with the same value are sorted at random. One way to see if a random
number generator is the source of the difference in your runs, so to do
something like this:

set seed 12345
do dofile1.do
do dofile2.do
etc.

set seed 12345
do dofile1.do
do dofile2.do
etc.

If the two runs result in the same numbers than you know that at some
point you inadvertantly used random numbers, possibly through -sort-.

Hope this helps,
Maarten

--- krishanu karmakar <krishkarmakar@gmail.com> wrote:

> Dear Statalist and Stata Using Friends,
> 
> I am facing a peculiar problem.
> 
> I am working on a pc with MS Home XP, 1GB Ram and Stata 9.2.
> 
> I am working with a survey data. I have extracted the data from the
> fixed format data files using dictionary files and -infile- command.
> I
> had to merge a few files to reach a consolidated data set.
> Subsequently I have saved this consolidated dataset in the .dta
> format. This is the data set I am working with. I am working with  a
> series of do files so that I need not save the dataset every time I
> make some data modification. I just run all the do files to reach at
> the required stage of analysis.
> 
> i have just noticed the following problem. I start Stata by clicking
> on the .dta file and run the series of do files and get some results.
> Now in the same session of Stata if I use -clear- and then read the
> data set again with -use- command and run the same set of do files I
> get some difference in results. The difference in result is mostly
> noticed for the -count- commands (with some complicated -if-
> conditions). Since the do files are large, I am not printing them in
> this mail. I would appreciate if some of you could throw some light
> on
> the problem if at least from some generic point. I am saying "from
> some generic point" because I can understand that with the above
> information it will be difficult to give a specific solution to my
> problem.
> 
> Any help is deeply appreciated.
> 
> Regards
> 
> Krishanu
> -- 
> Read it: http://www.stata.com/support/faqs/res/statalist.html
> Specially Question 3.
> *
> *   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/
> 


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com

*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index