On Thu, 3 Apr 2008, Riccardo (Jack) Lucchetti wrote:
Ok, I think I've now sussed out what the issue is. Allin,
correct me if I'm wrong.
When exiting the function, we clean up all local variables. One
of these is the local copy of "cirank", which is #12. This,
however, won't get deleted because the last estimated model in
the stack is a VAR, which contains the variable "endotilde3",
whose number is #35. So #12 gets expunged from the "morituri"
list, the list length becomes 0, no error is flagged, and i goes
back and forth from 11 and 12.
This sounds very plausible. I'd forgotten about the block on
deleting variables whose deletion would cause variables referenced
in stacked models (including VARs) to become renumbered.
The simple fix, I think, is not to decrement i until we know that
the variable in question really has been deleted. However, this
issue raises the question of whether the last model estimated
within a function that is returning should really be treated as
the "last model".
For now, I'm committing the "simple fix" to CVS just so you can
take a look.
Allin.