On Mon, 26 Aug 2019, Riccardo (Jack) Lucchetti wrote:
I have another idea: at present, we allow
<hansl>
series x = matrix
</hansl>
provided the matrix in question has the right number of rows and one column.
In many cases, it'd be very useful to have a parallel "multivariate"
construct, such as
<pseudo-hansl>
list X = matrix
</pseudo-hansl>
which would generate the series X_01, X_02, etc (of course, if rows(matrix)
== $nobs). The identifiers could be taken from the column labels, if present,
or the list name by default as in my example. This would be quite handy, I
think.
I agree. But several policies have to be decided in the
implementation of this. Here's what's in current git on the
"newcomplex" branch.
1) As with other "genr" things, the current sample range is
respected in creating or modifying series: we will not write outside
of that range.
2) We have to able to match rows of the matrix to observations in
the dataset. We do this by using the t1 and t2 tags attached to the
matrix, if present (in which case it's an error if there's no
overlap between the matrix t1 to t2 range and the current sample
range). Otherwise we match if the number of rows equals the number
of observations (a) in the dataset as a whole or (b) in the current
sample range. Otherwise error.
3) We need valid series names. If the matrix has column names we use
them. It's then an error if any of them are not valid identifiers,
or if there are any duplicates among them. If the source matrix
doesn't have column names we use the name of the matrix itself (if
it's named), or failing that the name of the list to which the new
series are being assigned. We append column numbers for uniqueness
and it's an error if the matrix or list name is too long to
accomodate the suffix.
4) If any of the names thus constructed are names of existing
non-series objects, an error is flagged and no list is produced. If
any of them are names of pre-existing series, the original series
are over-written over the current sample range.
Allin