is there an inarray function?
by Logan Kelly

Hello,
I need a function the tests if variable is in an array (sorry for the poor wording of this sentence). What I mean by this is a function that compares each element of an array to a variable and returns 0 if no elements of the array are equal and the position in the array of the first instance of equality. So here are my question:
1. Dose such a function exist? (I haven't found one, but I thought I should ask)
2. If not, coding it up is no problem, but I need a way to check the data type of variable. Is there such a command?
3. Is there a way, other than using a bundle, to pass a variable of unknown data type to a function?
Thanks,
Logan
8 years, 2 months

movavg() issues with gappy time series data
by Sven Schreiber

Hi,
it seems to me that movavg() (and perhaps other "intertemporal"
functions as well?) could/should also handle missing values in the
middle of time series, and not only like they currently seem to be doing
at the start or end.
Consider this example, where a manual moving average calculation works
just fine (of course producing NAs where required data are missing, but
that's ok), but the built-in movavg() function refuses to do anything:
<hansl>
nulldata 10
setobs 1 1 --time-series
series in = NA # some missings, but...
smpl 6 10 # ... a sub-sample...
series in = index # ...with valid values
smpl --full
# compare built-in and manual mov. avg.
series outma = movavg(in, 4)
series outclone = (in + in(-1) + in(-2) + in(-3)) / 4
d = sum(abs(outma - outclone)) # ok, same results
# now set 1st obs as non-missing, too
in[1] = 0
# again (try to) compare
series outclone2 = (in + in(-1) + in(-2) + in(-3)) / 4
catch series outma2 = movavg(in, 4) # missing value error
if $error
print outclone2 # ok with some missings (of course)
endif
</hansl>
This is with yesterday's snapshot (on Win 8). If you're wondering why
time series would have gaps in the middle, well this happens with
real-world data for example from Eurostat.
And next a related but conceptually more difficult thing with movavg():
If I restrict the sample to non-missing values, I can apply movavg, but
the results are misleading, because gretl "forgets" that this is not
really a contiguous time series anymore. (The fourth non-missing lagged
value for example can be much farther in the past than four periods.)
Intuitively I'd say that such "intertemporal" functions should require
time-series data and not work on "undated" sub-samples, but OTOH I know
that such "undated" sub-samples are often the outcome of sample
restrictions that you cannot avoid and where it would be annoying if
suddenly movavg() & co. didn't work anymore. So no concrete suggestion
here, just food for thought.
thanks,
sven
8 years, 2 months

NA not recognized by isnan()
by Sven Schreiber

Hi,
this is weird:
<hansl>
s0 = NA
print s0
a = isnan(s0) # gives 0!?
</hansl>
Latest snapshot on Win8.
BTW, gretl now feels extremely sluggish, and the Windows task manager
shows it to consume very little memory (<30MB). I will try to downgrade
to earlier snapshots or the latest release to check this.
thanks,
sven
8 years, 2 months

a new crash with eval
by Sven Schreiber

Hi,
I was trying to build a habit of using 'eval', and ran into this crash:
<crashing-code>
open denmark
ols IBO const IDE
eval $coeff[IDE]
</crashing-code>
Could well be a syntax mistake there, but of course that's not the point...
thanks,
sven
8 years, 2 months

matrix element not always scalar?
by Sven Schreiber

Hi,
this is giving me a datatype (not matching...) error:
<hansl>
m = I(3)
eval m[2,2] # gives scalar 1
x = xmin(1, 3) # works (of course)
x = xmin(m[2,2], 3) # but this doesn't
</hansl>
AFAICS it should be considered a bug.
thanks,
sven
8 years, 2 months

clash of $h (and perhaps other accessors) with loop index variables
by Sven Schreiber

Hi,
recently it happened to me that I used 'h' as a foreach loop index and
then got a problem when I wanted to access the string content with $h.
The reason was the fact that '$h' is an accessor in its own right.
So perhaps all gretl accessors would need to be made reserved words in
their form without the dollar sign? That is, gretl would complain when
you tried to use 'h'.
thanks,
sven
8 years, 2 months

qlrtest
by Artur T.

I have noted that it is now possible to define a list of variables to test
for parameter stability which is is really nice!
Nevertheless, even though the break date is provided in the print-out there
is possibility to access this break date. Given that it's possible to store
the test statistics and pvalue, why is it not possible to store the date?
Best,
Artur
8 years, 2 months

(no subject)
by Artur T.

Hi all,
I just wanted to run a script which worked properly around 3 months ago
(using current cvs at this time on Win 7).
I set up two inner loops (called LOOP and j, respectively) and have the
following command:
<hansl>
matrix b_D$LOOP_E$j_sim = zeros(n_rep,ncoff)
</hansl>
Unfortunately this is not working any more with a ten days old csv, and I
obtain the following msg:
"Varname 'b_D$LOOP_E$j_sim' contains illegal character '$'
Use only letters, digits and underscore"
Is this intended and a side-effect of the recent code-clean-up?
Artur
8 years, 2 months

exp domain error even though missings are "deactivated"
by Sven Schreiber

Hi,
I'm trying to work with matrices converted from series/lists that
contain missings, in order to vectorize and hopefully speed up code.
I'm working around the fact that misszero() doesn't work for matrices by
using the ternary operator to only apply formulas selectively to the
non-missings. (I vaguely remember a discussion about matrices and
misszero(), but don't recall the details anymore. Probably I should go
and dig it up in the archives.)
One thing I'm puzzled about is that I get "domain error" warnings about
the exp() function, even though I only apply it to the non-missings.
Example:
<hansl>
a = exp(NA) # memo: no "domain error" for the scalar case
matrix m = I(4)
matrix m2 = !m ? NA : m # create some "nan" in a matrix
print m2 # look at the nan, they're there!
matrix check = exp(m2) # "domain error" ok, expected
matrix m3 = isnan(m2) ? 0 : exp(m2) # but why here?
</hansl>
After the last line m3 doesn't contain missings/nan, and so the code
works, but then why the warning message? I could imagine that both
branches of the ternary operation are executed and then afterwards the
needed results are collected and combined, but that would seem quite
inefficient computationally, no?
thanks,
sven
8 years, 2 months

logit problem
by Sven Schreiber

Hi,
when 'logit' is automatically dropping variables (or observations?)
because of perfect prediction, there is a problem it seems:
<hansl>
open abdata.gdt
series binary = (INDOUTPT > INDOUTPT(-1))
series bincheck = binary
logit binary const EMP bincheck
</hansl>
produces this error message here:
<error>
Note: bincheck != 0 predicts success perfectly
338 observations not used
Not a Number geschah bei Berechnung
Fehler bei Skriptausführung: Stopp
> logit binary const EMP bincheck
</error>
(BTW, note the non-translated strings, perhaps they still need to be
marked for translation?)
Thanks,
sven
8 years, 2 months