I've recently been working on a gretl function to implement the
panel unit-root test of Breuer, McNown and Wallace (Oxford
Bulletin of Economics and Statistics, 2002), which takes into
account cross-equation correlations while allowing for
the testing of the unit-root null on a per-group basis.
In that context I realized that -- unless I'm missing something --
we didn't have a means of constructing a "system" spec on the fly
(when the number and make-up of the equations is not known until
run-time). Possibly one could do domething cunning but ugly with
strings, but I couldn't see any other way.
So in CVS I've implemented a generalization of the system spec.
I'm not sure that my approach is the best one: it has the virtue
of causing the least disruption to existing gretl types and
command structures, but has some limitations. So I'd like to
invite comments.
Here's the deal: Up till now the only thing accepted by way of
specification of the equations in a "system" block has been a set
of "equation" statements, but now you can say
equations <matrix-name>
Note the plural in "equations". The parameter should be the name
of a pre-defined matrix, each row of which represents a list
(left-hand side variable, regressors). If some lists are longer
than others, the matrix should have g columns where g is the
length of the longest list, and shorter lists should be padded
with trailing zeros.
It works, but has a couple of limitations:
(1) Since trailing zeros are ignored, you can't place the constant
at the end of an equation list. This shouldn't be a real problem,
since you are better placing the constant first; it will be
shuffled into first place by gretl anyway.
(2) You can't insert the equivalent of ";" into a matrix, and so
you cannot specify an equation's list "tsls-style". This is a
problem only (a) if you are using instruments and (b) you want to
use specific instruments in specific equations rather than using a
common set of instruments for all equations.
Here's a simple example (it's not complete, and presumes some
"stage-setting", but might convey the idea):
scalar g = <whatever>
scalar listmax = <whatever>
matrix surrow
matrix surmat = zeros(g, listmax)
loop i=1..g
# build g lists and insert into matrix surmat
p = laglengths[i]
list eqlist = xd$i const x$i(-1) xd$i(-1 to p)
matrix surrow = eqlist
k = nelem(eqlist)
if (k < listmax)
# this equation is "short"
surrow ~= zeros(listmax - k)
endif
surmat[i,] = surrow
endloop
system method=SUR
equations surmat
end system
Allin