On Thu, 22 Oct 2009, Allin Cottrell wrote:
On Thu, 22 Oct 2009, Artur T. wrote:
> I am surprised that it is not possible to save models within the
> loop function. I really thought that this worked some versions
> ago, but I might e wrong.
I'm not 100% certain, but pretty sure this has never worked. The
difficulty is that commands within a loop are handled "deep
inside" libgretl, as opposed to commands registered via GUI
point-and-click or the gui console. (The processing of commands
within a loop is shared between the gretl GUI program and
gretlcli, which has no concept of "named models".)
So to get this sort of thing to work we need to exploit a
"callback function" from libgretl to the GUI program, whereby
libgretl says, "Hey, the user wants to save this model under a
given name, can you handle that?".
As it happens, I'm working on that right now (I started earlier
today). What I'm aiming to implement is:
* the ability to save a named model within a loop;
* the ability to add the last model to the "model table" within a
loop; plus
* the corresponding functionality for graphs within loops (save
named graph; add graph to the GUI "graph page").
So this is something that, hopefully, should be available before
too long.
FWIW, I'm not entirely enthusiastic about this kind of thing. Sure, the
more you can do (especially in a script), the better. But my spider sense
is tingling --- there are many many things that can go wrong with this
apparatus.
By the way, what's the point of storing models in a loop? The only
situation I can think of is when you have to apply the same estimation
method over and over again and need to compare the results at the end.
Except when you have very few of them, you probably won't want to compare
them by clicking on each model in turn and having a gazillion windows open
on your desktop. What you probably want to do is store the relevant
quantities (coefficients, residuals, information criteria) somewhere (in a
matrix, a text file, whatever) and start from there.
That said, I would love to be wrong!
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti