Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: loop


From   Carlos Aller <caller@merlin.fae.ua.es>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: loop
Date   Tue, 15 Nov 2011 22:18:25 +0100

El 15/11/2011 18:33, Jorge Eduardo Pérez Pérez escribió:
You can use -capture- and  -continue-, see the help for those
commands. For example, in the following code, the second set of
initial values causes non-convergence, so Stata produces an error
message and goes on with the next iteration.

sysuse auto, clear
* Define three sets of initial values
local i1="0 0"
local i2="-2000 -2000"
local i3="10 10"
* Loop over initial values
foreach x in i1 i2 i3 {
	cap nois logit foreign mpg, from(``x'', copy) iter(100) nolog
	if _rc continue
}

_______________________
Jorge Eduardo Pérez Pérez




On Tue, Nov 15, 2011 at 12:05 PM, Carlos Aller<caller@merlin.fae.ua.es>  wrote:
Dear statalisters

I've designed a loop  so in each iteration I assign different initial
values to my estimator. The problem is when the estimation do not
achieve convergence and the program stops. The "no stop" command permits
to continue with the program but skips the loop and what I wanna get is
to continue the loop with the next iteration. Do you know how to do it?

Thanks in advanced,
Carlos.
*
*   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/



It works!

Thank you very much,
Carlos.
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index