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   "krishanu karmakar" <[email protected]>
To   [email protected]
Subject   Re: st: Running the same do file but getting different results
Date   Sun, 10 Feb 2008 02:23:44 +0530

Respected Mr. Buis,

Thank you very much. Indeed, I have used the sort command and the
relevant variable is an id variable for individuals. Incidentally that
is "repeated" for some observations as the same individual may have
fallen ill in the reference period more than once. I think I need to
use the serial number of illness as the secondary sort variable along
with the id variable.

Thank you very much again for your kind help.

Regards

Krishanu



On Feb 10, 2008 2:02 AM, Maarten buis <[email protected]> wrote:
> 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 <[email protected]> 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/
>



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



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