very easy crash bug
by Sven Schreiber
Hi,
it seems that a lonely unmatched function call parentheses pair in a
script editor window can crash gretl on execution. For example the line
"eval mean(" led to gretl crashing when clicking the execute button.
(Latest snapshot.)
thanks
sven
3 years, 9 months
inverse of stack() function
by Riccardo (Jack) Lucchetti
We have the very nice stack() function, that helps you turn a list of
series into a single panel series. Unless I'm missing something, I don't
think we have the opposite function, that is a function turning a
panel series into a multi-column object. So, I ended up writing this:
<hansl>
set verbose off
function matrix unstack(series x, series names)
errorif($datatype != 3, "This function needs panel data")
scalar N = $nobs / $pd
set skip_missing off
matrix mat = mshape({x}, $pd, N)
strings lab0 = strvals(names)
strings lab1 = array(N)
ndx = uniq(names) # ordering could be garbled
loop i = 1 .. N
j = ndx[i]
lab1[i] = fixname(lab0[j])
endloop
cnameset(mat, lab1)
return mat
end function
###
### example
###
open grunfeld.gdt
matrix mat = unstack(invest, firmname)
# save as a dataset and reopen it
y0 = sprintf("%d", min(year))
fname = "@dotdir/tmp.gdt"
store "@fname" --matrix=mat
open "@fname" --preserve
setobs 1 @y0
</hansl>
My question is: is there a simpler way to accomplish the above? And if
there isn't, would it be worthwhile to add this function to the extra
package?
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------
3 years, 9 months
CRASH: passed integer value out-of bounds
by atecon
Hi,
with latest git version under Ubuntu 18.04 I obtain a crash when running
the following script:
<hansl>
clear
set verbose off
function void simple (const int N[2::])
print "very simple"
end function
simple(1)
</hansl>
The shell prints:
<shell-output>
free(): double free detected in tcache 2
Aborted (core dumped)
<shell-output>
Hope that helps.
Artur
3 years, 9 months
Re: Theil's U1 for fcstats (reloaded)
by Sven Schreiber
Am 03.03.2021 um 11:54 schrieb ESTEVEZ NUÑEZ JUAN CARLOS:
> ... and talking about this, may be a good chance to review what´s the
> sense of gretl
> to show Theil statistic in forecast output, with cross-section data. 🙂
>
If there's any problem, you don't have to wait for somebody else to
start a topic where the keyword appears :-)
It's always best to start a new thread for a different topic.
But anyway, can you give an example of what you mean?
thanks
sven
3 years, 9 months
Theil's U1 for fcstats (reloaded)
by Sven Schreiber
Hi,
an old issue resurfaced here recently, and I dug out this old thread:
(hope the link works, it starts on May 6th, 2017:)
https://gretlml.univpm.it/hyperkitty/list/gretl-devel@gretlml.univpm.it/t...
The point is that we might want to have Theil's U1 measure in addition
to the U2 measure which is in fcstats() and in the guide. U1 has a
different interpretation, but also works if some values are zero.
The guide says in a footnote: "This statistic is sometimes called U 2,
to distinguish it from a related but different U defined in an earlier
work by Theil (1961). It seems to be generally accepted that the later
version of Theil’s U is a superior statistic, so we ignore the earlier
version here."
But I don't think it's purely a matter of superior or not, it's just
different.
(For U1 I'm quoting myself:
"U1 being basically, using some obvious notation:
numerator = sqrt(mean((my-mfc).^2))
denom = sqrt(mean(mfc.^2)) + sqrt(mean(my.^2))
out = numerator/denom
-- This only breaks down if all observations are zero and if those are
all correctly and exactly forecast.")
Would it be OK to simply extend the result of fcstats()?
thanks
sven
3 years, 9 months
string to be marked for translation?
by Sven Schreiber
Hi,
could these be strings that are not marked?
lib/src/dbread.c 2401:
gretl_warnmsg_sprintf("ODBC import: '%s': no valid observations in
sample range", vnames[i]);
lib/src/gretl_midas.c 323:
gretl_warnmsg_set("The argument does not seem to be a MIDAS list");
lib/src/libset.c 599:
gretl_warnmsg_set("set_omp_n_threads: OpenMP is not enabled");
lib/src/libset.c 588:
gretl_errmsg_sprintf("omp_num_threads: must be >= 1 and <= %d",
gretl_n_processors());
lib/src/tokenize.c 2413:
gretl_warnmsg_sprintf("\"%s\": obsolete %s; please use \"%s\"",
lib/src/tokenize.c 2043:
gretl_errmsg_set("catch: cannot be applied to this command");
lib/src/tokenize.c 2060:
gretl_errmsg_set("savename is too long");
lib/src/tokenize.c 2612:
gretl_errmsg_set("'end loop': did you mean 'endloop'");
lib/src/tokenize.c 3319:
gretl_errmsg_sprintf("end: invalid parameter '%s'", cmd->param);
lib/src/transforms.c 1464:
gretl_warnmsg_set("The argument does not seem to be a MIDAS list");
lib/src/transforms.c: 1696:
gretl_errmsg_sprintf("%s: collides with existing object name",
vname);
lib/src/transforms.c 1753:
gretl_warnmsg_set("The argument does not seem to be a MIDAS list");
If the diagnosis is correct, I could apply the changes - in these cases
it's just enclosing them in _(), right?
thanks
sven
3 years, 9 months
inconsistent naming of periodic dummies
by Artur Tarassow
Hi,
just by chance I found that periodic dummies are not named consistently.
Currently we have:
- quarterly data: dq1 to dq4
- monthly data: dm1 to dm12
- daily (5 days): dummy_1 to dummy_5
I am wondering whether some harmonization is useful here?
<hansl>
clear
set verbose off
# quarterly dq*
open AWM18.gdt -q
list L = dataset
genr dummy
list N = dataset - L
N
# monthly -- dm*
open hamilton.gdt -q
list L = dataset
genr dummy
list N = dataset - L
N
# Daily (5 days) -- dummy_*
open b-g.gdt -q
eval $datatype
list L = dataset
genr dummy
list N = dataset - L
</hansl>
Best,
Artur
3 years, 10 months
nonlinearity tests, etc. (2)
by Allin Cottrell
On Sun, 28 Feb 2021, Sven Schreiber wrote:
>>> I guess it would be useful if we could include the popular BDS test:
>>> Brock, Dechert and Scheinkman (1987) (and later published as Brock,
>>> Dechert, Scheinkman and LeBaron, 1996; apparently there is some C code
>>> by LeBaron from 1997, LeBaron, B.(1997). “A Fast Algorithm for the BDS
>>> Statistic”, Studies in Nonlinear Dynamics and Econometrics, 2, 53-59,
>>> but maybe not necessary?) [...]
I can see this could be useful if you just have a residual series
you want to test (e.g. after ARMA). So I've put it into git on a
trial basis. There's a new C-plugin, bdstest, which supports (for
now) a "hidden" function, _bdstest(). It's based on LeBaron's "fast"
code. The signature of the hidden function is:
matrix _bdstest(series x, int m, scalar eps)
where m is the embedding level (>= 2) and eps the cut-off for
"closeness". Right now eps is just a raw number in the units of x,
but if we pursue this it should probably be expressed as a fraction
of the standard deviation of x (a rule of thumb seems to be eps =
0.5*sd(x)).
The return value is a column vector of m-1 z-scores, for testing at
embedding levels 2 to m.
I'm attaching LeBaron's sample data as x.txt, and the output from
his original program as output.txt. You can replicate this via
<hansl>
open x.txt
matrix B = _bdstest(x, 5, 100)
print B
</hansl>
The plugin file bdstest.c can also be copied out of the source tree
and compiled as a stand-alone "libgretl program", by defining
STANDALONE to 1 near the top of the file. In that mode the program
does Monte Carlo, which reveals that the test over-rejects quite
substantially for series of typical econometric length -- so if we
pursue this we may want to look into MBDS. The MC parameters are
mostly hard-wired; edit the C to change things.
Allin
3 years, 10 months
the getinfo() function: request for comments
by Riccardo (Jack) Lucchetti
The getinfo() function, as you know, is used to for retrieving the
metadata of a series. For example, the code
<hansl>
open data4-1 -q
b = getinfo(sqft)
print b
</hansl>
returns
<output>
bundle b:
coded = 0
transform = "none"
parent = ""
discrete = 0
name = "sqft"
description = "square feet of living area (Range 1065 - 3000)"
lag = 0
has_string_table = 0
</output>
The function currently returns an error if applied to a series that is
created "on the fly", as in "getinfo(log(sqrt))". This is IMO undesirable,
so I was going to modify the function to have it return a bundle anyway.
The question is: what should it contain? I was inclined to fill all the
slots with "sensible" values, perhaps setting "name" as "anonymous" and
"description" with something meaningful if possible. Or should we just
return an empty bundle? Would it make sense to include an "anonymous"
binary flag? Something else?
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------
3 years, 10 months