Am 15.07.20 um 20:02 schrieb Allin Cottrell:
On Wed, 15 Jul 2020, atecon(a)posteo.de wrote:
> Hi,
> as nobody replied, yet: Can anybody confirm this behaviour?
The reference is to
https://www.mail-archive.com/gretl-users@gretlml.univpm.it/msg14808.html
Yes, I can confirm the behavior described there, but I don't think
it's a bug. Restricting the sample cannot change the fact that
Chrysler is firm 4 of 10 in the grunfeld dataset, and so the
string-valued "firmname" series must comprise at least 10 strings.
Otherwise it would be impossible to undo the restriction.
Thanks for your response, Allin.
But what about the case when adding the " --permanent" flag? In this
case one cannot undo the restriction but my example would still return a
string array of length 11.
If you want to destroy that information and reconstitute the string
values on a smaller scale you can
1) Impose the sample restriction
2) Save the reduced dataset as CSV
3) Open the CSV and save as gdt
But this was exactly the example I came up with. The only difference is
that I tried to store a gdt instead of a csv file. And here the surprise
comes: When storing a restricted data set as a csv file and re-opening
it, things are as, at least me, I would expect:
<hansl>
smpl firmname == "Chrysler" --restrict
store foo.csv
open foo.csv -q -p
eval strvals(firmname) # [1] "Chrysler"
</hansl>
But once one tries to store things in the gdt or gdtb format, the length
of the array is still of length 11. Why does it or should it matter in
which format things are stored here?
On a related matter, you can inspect the string values of a subset of
the grunfeld data in a fairly straightforward way:
<hansl>
open grunfeld.gdt
# e.g. restrict to even-numbered firms
smpl firm % 2 == 0 --restrict
strings S2 = strvals(firmname)[values(firmname)]
print S2
</hansl>
Ah thanks, good to know. For some reason I rarely make use of this
modulus operator.