On Tue, 9 Jun 2009, Renju Jacob wrote:
I was pondering over a question about gretl. Say, I use one
script session to compute nls mutliple times. Now, in one of the
iterations, the script encounters an error (eg missing values,
failed Jacobian etc). Is there a way for me to tell it to
continue going through the rest of the script without halting?
Good question. We have two mechanisms that are supposed to be
relevant here. You can set the environment variable
GRETL_KEEP_GOING (e.g. GRETL_KEEP_GOING=1), or you can use the
"set" command:
set halt_on_error off
However, I realized recently that neither of these options was
working quite as intended (although the environment variable
approach should work OK with gretlcli). I've therefore made some
changes in CVS and the current Windows snapshot, and I think
setting halt_on_error to "off" should now do the job.
Two further points:
1) If an error occurs when "compiling" a loop or user-defined
function, script execution will halt regardless.
2) I have added a "--continue" option for the commands arma,
garch, nls, mle and gmm. This is a weaker, and perhaps more
useful, variant on setting halt_on_error off. The effect is that
if a _numerical_ error occurs (e.g. non-convergence, failure to
compute the Jacobian) gretl continues, but sets the internal
variable $error to a non-zero value. (If a non-numerical error,
such as failure to allocate memory, occurs, gretl halts as usual.)
Therefore, after using one of these commands with the --continue
option, you can check the value of $error and act appropriately.
Note that while you cannot set the value of $error yourself,
referencing "$error" causes this variable to be reset to zero.
Allin Cottrell