In my reply, at
http://lists.wfu.edu/pipermail/gretl-devel/2018-September/009010.html
to Sven's post on the kinda weird stack() "function" at
http://lists.wfu.edu/pipermail/gretl-devel/2018-September/009009.html
I finished by saying,
So what should we do? We could make the implicit "panelize"
command explicit -- but to avoid breaking old scripts we should
presumably continue to accept stack() as documented at present.
However, this whole apparatus, IIRC, pre-dates easy traffic
between series and matrices, and it seems to me that a modern
approach to panelization of an imported dataset in gretl would
probably go via matrices rather than using stack().
And I thereby left the business unresolved! Here's an attempt at
resolution. It turns out that the problem for which stack() provides
a solution is pretty easily handled by
series -> matrix -> reshape matrix -> series
The problem is described in section 4.5 of the Gretl User's Guide.
That is, we import some panel data that are organized "by variable":
T columns hold the time periods and N rows the "units" or
individuals. More than one variable may be given in such a file, in
which case we assume the k variables are stacked vertically so the
data block as a whole has N*k rows and T columns. How do we make a
gretl panel dataset out of this?
The matrix solution goes as follows, where I assume the "by
variable" data are in foo.csv (with no extraneous rows) and there
are N=10 individuals. (The value of N is the only "extra"
information, not present as such in foo.csv, that is needed.)
<hansl>
open foo.csv
N = 10 # number of individuals
set skip_missing off
matrix X = {dataset}
set skip_missing on
T = cols(X) # number of periods
NT = N * T # total panel series length
k = nelem(X)/NT # "real" number of series
X = mshape(X', NT, k)
nulldata NT --preserve
setobs T 1:1 --stacked-time-series
list Panelvars = null
loop i=1..k --quiet
Panelvars += genseries(sprintf("x%d", i), X[,i])
endloop
store panelized.gdt Panelvars
</hansl>
So here's a suggestion: in section 4.5 of the Guide I delete the
discussion of the fix using the mysterious stack() in favour of an
example and explanation of the method illustrated above.
Should I do that? If so, stack would then be undocumented, but we
could keep it for the time being for backward compatibility.
Allin