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: Nostop in do files


From   Sergiy Radyakin <[email protected]>
To   [email protected]
Subject   Re: st: Nostop in do files
Date   Wed, 27 Oct 2010 10:44:08 -0400

On Wed, Oct 27, 2010 at 10:11 AM, Katia Bobulova
<[email protected]> wrote:
> thank you very much for your help.
>
> Your suggestion it is fine because there isn't an interruption of the
> file do when the convergence is not possible, however, each time that
> is not possible to reach the convergence the file do restart from the
> beginning.
>
> Any ideas?

Plenty, but please provide more details on what you are doing.

Capture protects a certain section of your program, that section is
treated as one unit, it either
works or not(*). If your program (do-file) has structure P=A->B->C and
B may potentially fail with
an error and you want C to run anyways, than B should be wrapped in
-capture-, not the whole
A->B->C.

However if C depends (!) on the results obtained in B, then if B fails
there is no point in running C,
and the whole A->B->C should be wrapped in -capture-.

Which one is your case - I don't know. Consider the following
examples: if after estimation of a
model you estimate a different model, or try a different estimation
strategy of the same model,
then you do want that part to run regardless of the success in the
first one. Then use -capture-
around the first part only.If after estimation of model you want to do
a prediction, then the
prediction naturally depends on the results of the model estimation
and should not be done if
the model is not estimated.

Best, Sergiy Radyakin


(*) unless it contains -capture- within, then it gets more complicated


>
> Thanks,
> Katia
>
> 2010/10/26 Sergiy Radyakin <[email protected]>:
>> Sure there is an alternative:
>>
>> 1) runs the same file 10 times with different parameters:
>>
>> forvalues i=1/10 {
>>   capture noisily do "C:\PROGRAMS\mydofile.do" `i'
>> }
>>
>> Runs mydofile.do 10 times, tolerating errors in each run-iteration.
>> Value of i is passed as a parameter.
>> Depending on what you are doing, you may want to form the actual
>> parameters outside and pass to the
>> do-file or inside of the do-file, based on the iteration number.
>>
>> Remove -noisily- if you do not need the output of individual iterations.
>>
>> 2) runs 10 do-files one time each:
>> forvalues i=1/10 {
>>   capture noisily do "C:\PROGRAMS\mydofile`i'.do"
>> }
>>
>> (files must be named mydofile1.do, mydofile2.do, etc)
>>
>> Best,
>>   Sergiy Radyakin
>>
>>
>>
>>
>> On Tue, Oct 26, 2010 at 2:32 PM, Katia Bobulova
>> <[email protected]> wrote:
>>> Dear Neil,
>>>
>>> thank you very much for your answer. Now I sorted out the problem with
>>> the do file and it works, however, still my do file stops, even with
>>> the nostop option.
>>>
>>> I receive this error message:
>>> convergence not achieved
>>> r(430);
>>>
>>> But the nostop option is not meant to overcome this problem??
>>>
>>> Is there something else that must be specified?
>>>
>>> thanks
>>> Katia
>>>
>>> 2010/10/22 Neil Shephard <[email protected]>:
>>>> On Fri, Oct 22, 2010 at 3:19 PM, Katia Bobulova
>>>> <[email protected]> wrote:
>>>>> The option could be dangerous, but it is useful for preliminary analysis.
>>>>>
>>>>> I have bot the data and the do files in the same folder.
>>>>>
>>>>> So I open the dataset and then I type:
>>>>> do 2000, nostop
>>>>>
>>>>> where 2000 is the name of my do file I receive the message file
>>>>> 2000.do not found
>>>>>
>>>>> Could you please help me to solve this problem?
>>>>
>>>> Without output its pretty hard to tell, but I'll hazard a guess at
>>>> what you're doing...
>>>>
>>>> 1) You start up Stata
>>>>
>>>> 2) You open your file with File -> Open, navigate to the location and
>>>> open the dataset
>>>>
>>>> 3) You now type 'do 2000, nostop' and get told the file isn't found.
>>>>
>>>> This is because whilst the data file and do file are in the same
>>>> location, Stata is not currently "in" that directory.
>>>>
>>>> Type -pwd- to see what directory Stata is in, if the output of this is
>>>> NOT the directory where your files are then use the -cd- command to
>>>> change directory to the location of the files.
>>>>
>>>> I'll further hazard that your on M$-Windoze, so something like...
>>>>
>>>> cd "c:/this/is/where/i/have/saved/my/files"
>>>> use mydata, clear
>>>> do 2000, nostop
>>>>
>>>> ...should hopefully achieve what you are trying to do (although
>>>> obviously substituting the directory path (
>>>> "c:/this/is/where/i/have/saved/my/files" double quotes are important
>>>> if you have a space in the path) for where you have actually saved it,
>>>> and the data file name for the name you have called your data
>>>> ("mydata", again double quotes are important if you have a space in
>>>> the filename)).
>>>>
>>>> Personally I never touch the menu system in Stata, insteading working
>>>> exlusively with do-files and -cd-ing to the relevant directory first.
>>>>
>>>> These are very basic (and fundamental) steps to working with Stata.  I
>>>> would recommend one of the introductory texts to Stata available from
>>>> Stata Press such as...
>>>>
>>>> http://www.stata-press.com/books/acock3.html
>>>> http://www.stata-press.com/books/ishr3.html
>>>> http://www.stata-press.com/books/daus2.html
>>>>
>>>> ..or similar.  Alternatively you may find the the Stata NetCourse
>>>> useful http://www.stata.com/netcourse/nc101.html which covers these
>>>> basics.
>>>>
>>>> Neil
>>>>
>>>> --
>>>> "Our civilization would be pitifully immature without the intellectual
>>>> revolution led by Darwin" - Motoo Kimura, The Neutral Theory of
>>>> Molecular Evolution
>>>>
>>>> Email - [email protected]
>>>> Website - http://kimura-no-ip.org/
>>>> Photos - http://www.flickr.com/photos/slackline/
>>>> *
>>>> *   For searches and help try:
>>>> *   http://www.stata.com/help.cgi?search
>>>> *   http://www.stata.com/support/statalist/faq
>>>> *   http://www.ats.ucla.edu/stat/stata/
>>>>
>>>
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/statalist/faq
>>> *   http://www.ats.ucla.edu/stat/stata/
>>>
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

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


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