On Fri, 14 Sep 2012, Riccardo (Jack) Lucchetti wrote:
On Fri, 14 Sep 2012, Annaert Jan wrote:
> Would it be a big deal to allow the freq command to operate on vectors? I
> know I can convert the vector into a series and then use the freq command.
> But especially when the number of elements in the vector is larger than the
> dataset's dimension this because somewhat more cumbersome. A freq command
> accepting a column (or row) vector as input would be a real time-saver…
I agree, it would be nice to have. In the meantime, you could adapt to your
needs the following code snippet:
<hansl>
x = ceil(muniform(400,1)*6)
frq = sumc(x .= values(x)')
print frq
</hansl>
As usual, a very nice compact piece of hansl script from Jack!
I agree, to a point, with the "nice to have" judgment, but...
There are two dualities in gretl/hansl that tend to run together
(though admittedly they do not always do so). These are
series/matrices
and
commands/functions
That is, we have lots of commands that work on series (in some cases
named lists of series) but do not take matrices as arguments. On the
other hand we have lots of functions that work on matrices, and a
fair number that will work on either series or suitably dimensioned
matrices.
My feeling is that modifying the "freq" _command_ to handle matrices
would be a major disruption of the way gretl/hansl works: why, then,
should not all gretl commands that currently require series
arguments also work with matrices?
[As an aside here, the linked series/matrix and command/function
dualities in gretl are shared by several econometrics packages. We
intend to discuss this sort of thing in the hansl manual, which
hopefully will appear one day!]
What I've said above is quite compatible with adding a freq()
function that takes a vector (or series) argument. But then the
question is: what should such a function do, exactly? Should it
print stuff (if so, what?) and/or should it return some sort of
matrix of results?
This is not a rhetorical question (meaning: it's imponderable, it
can't be done), it's a genuine question looking for a good answer.
If a good answer is forthcoming I'd be happy to add a freq()
function.
Allin Cottrell