Function to get the powerset
by Henrique Andrade
Dear Gretl Community,
I really stuck trying to define a function that gives a power set of a
set. Suppose I have a set S:
S = {"A", "B", "C"}
The associated power set, P(S), is:
P(S) = {{ }, {"A"}, {"B"}, {"C"}, {"A", "B"}, {"A", "C"}, {"B", "C"},
{"A", "B", "C"}}
All that I can think by now (shame on me!) is this:
strings S = defarray("A", "B", "C")
scalar P_S_len = 2^nelem(S) # the size of the power set
strings P_S = array(P_S_len) # an array with 8 spaces.
Does anyone have any ideas?
Best,
Henrique Andrade
6 years, 3 months
warning: gdt-reading bug
by Allin Cottrell
We've just noticed that a bug was introduced into our code for reading
native gretl .gdt data files in August of this year. The bug should be
triggered only rarely, but we thought it wise to issue a warning.
Description of bug: If a gdt file contains "subnormal" values (that
is, floating point values that are too close to zero to be represented
with the usual precision), then when such a file is read on Linux, the
first subnormal value to be found on a given row (observation) will be
incorrectly copied into the remaining columns (series) on that row.
Example: A gdt file containing 10 series has a subnormal for series
number 5 on row 25. Then when the file is read on Linux, that
subnormal will replace the correct values for series 6 to 10 for
observation 25.
Comment: This won't affect the reading of "primary" data (actual
micro- or macroeconomic measurements), which will never contain
subnormal values (we're talking about absolute values less than 10 to
the minus 307). And the bug is not triggered on MS Windows. However,
subnormal values may be produced by some data transformations (such as
squaring very small numbers, or computing the normal CDF of very big
negative values).
Fix: This is now fixed in the git source for gretl and also the
current snapshots. And we will put out a new release soon, gretl
2015d.
Diagnostic: If you think a dataset may suffer from this problem,
you can run the script checkdata.inp, from
http://ricardo.ecn.wfu.edu/pub/gretl/checkdata.inp
First load the dataset in question. Then open checkdata.inp and run
it. An affected dataset may produce something like this:
<script-output>
Total number of values examined: 164122
Check for subnormal floating-point values
-----------------------------------------
Total number found: 138
Longest (row) sequence: 138
(occurs at obs 210, starting series ID 461)
Number of sequences (of length >= 2): 1
</script-output>
The symptom of a problem is that we find a consecutive sequence of
subnormal values on one or more rows of the dataset. This could occur
for "natural" reasons but it may indicate corruption. Isolated
subnormals don't indicate the bug. And again, most datasets should
contain no subnormal values.
Allin Cottrell
8 years, 3 months
declare a list to a bundle
by Artur T.
Hi all,
I would like to declare a list "z" to a bundle "b" but I am surprised to
see that this doesn't seem to work:
<gretl>
open denmark.gdt --quiet
bundle b = null
list z = const LRM
b.z = z
</gretl>
Message: "The variable b is of type bundle, not acceptable in context"
Is this actually intended? Also, is there in alternative how to handle
this (I disregard the possibility to define a matrix which could be send
to "b" for the moment).
Best,
Artur
8 years, 4 months
SourceForge Poll
by Riccardo (Jack) Lucchetti
Gretl is one of the candidates for the SourceForge project of the month.
If you feel like voting for gretl, we'd be grateful. Apart from being a
ego boost for the developers, it would give some nice visibility to the
project as a whole.
Instructions here:
https://sourceforge.net/blog/community-choice-project-of-the-month-vote-n...
if you're not already a SourceForge member, you'll need to subscribe
first.
Thanks!
-------------------------------------------------------
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
-------------------------------------------------------
8 years, 4 months
Fan chart
by Riccardo (Jack) Lucchetti
Someone asked me instructions on how to produce a "fan chart" (aka "rivers
of blood" chart) in gretl. These are typically used for density forecasts.
So I wrote a little function that I'm sharing here, if anyone is
interested. It's very rough, but I'm sure anyone with a decent knowledge
of hansl can customise it as per their needs.
Attention developers: I'0m not using the newly-introduced "band" option to
plot here, since you need more than one at the same time. Maybe we could
think about extending the syntax to "plot" in the future.
<hansl>
function string fanchart(series y, series se, matrix alphas)
matrix a = mreverse(sort(vec(alphas)))
scalar n = rows(a)
matrix X = {y , misszero(se)}
strings colcodes = defarray("cccccc","888888","666666","333333")
scalar rand = ceil(1000*muniform(1,1))
string gfname = sprintf("\"@dotdir/tmp%03d.gp\"", rand)
string dfname = sprintf("@dotdir/tmp%03d.dat", rand)
outfile @gfname --write --quiet
printf "set nokey\nset ylabel '%s'\n", argname(y)
printf "plot \\\n"
loop i = 1..n --quiet
z = invcdf(z, 1 - (1-a[i])/2)
string code = colcodes[i]
printf "'%s' using 1:($2-%g*$3):($2+%g*$3) notitle lc rgb \"0x%s\" w filledcurve, \\\n", \
dfname, z, z, code
endloop
printf "'%s' using 1:2 w lines lt 1\n", dfname
outfile --close
outfile @dfname --write --quiet
loop i = 1..rows(X) --quiet
scalar tt = $obsmajor[i] + ($pd>1 ? ($obsminor[i] - 1)/$pd : 0)
printf "%g\t%g\t%g\n", tt, X[i,1], X[i,2]
endloop
outfile --close
return gfname
end function
# usage example
nulldata 48
setobs 12 1990:1 --special-time-series
scalar n = $nobs
series y = 0.1*time + filter(0.5*mnormal(n,1), 1, {1.8, -0.9})
series se = cum(time<$nobs/1.5 ? NA : uniform())
matrix alphas = {.83, 0.95, 0.99}
string haha = fanchart(y, se, alphas)
gnuplot --input=@haha --output=display
</hansl>
-------------------------------------------------------
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
-------------------------------------------------------
8 years, 4 months
About append and time series
by guido giaume
Dear all
I downloaded from Yahoo few years of a daily stock time series.
Before storing them into a singular yearly files, i cleaned them from
the "ghost data".
Maybe you knows, sometimes, Yahoo downloaded files shows data also when
markets are closed (e.g. 2016-01-01 for italian markets).
After the cleaning I tried to join two files (years) with the "append"
command (it does not matter by terminal, script or graphic interface).
I had no result (no appending) but i had a "success message" in a
dialog box (while using the graphic interface) and no clear error
message using terminal or script.
"append" seems not working with "cleaned" files (but of course in a
different situation "append" works fine) .
So I suppose there is a kind of default data integrity control.
I havent studied yet the "join" command so may be this problem is
solvable in others ways but I ask if i have chance to append my files
and if I am not wrong I suggest, for the next releases
some features
a) a better failure message for this case of the "append" command;
b) an option to "force" the appending of apparently non contiguous
data;
c) a possibility of managing data to insert back the cleaned data. I
tryed to insert a 2016-01-01 (ghost) value but i was unable to keep it
at the top of the data.
Thanks
Kind regards
Guido
8 years, 4 months
on yahoo finance data download
by guido giaume
Dear group
weeks ago I noticed there could be a malfunction on the package
yahoo_get .
I was wrong. It works fine.
After intensive trials with many ISP and hardwares it seems:
a) I had a problem on the firmware of my modem-router, making the line
instable;
b) there is an unclear API download policy from Yhaoo. I mean may be
there are some hidden limitation about downloading, which infringement
lead to a kind of ban.
But be careful, the ban is silent, so is not easy discover it.
Some people over internet says there is a limit of the tickers number
(200?) for each interrogation. It seems to me only a part of the
problem.
I think there is a problem of speed too: if the interrogation speed is
"too high" it seems to be considered malicious from the Yahoo firewall.
If somebody argue 200 tickers are a lot of data i remember the SP500
index is made of 500 tickers.
So at the moment
- I splitted the tickers list in many groups and
- I slowed down the speed of the script with this loop
loop for (r=1; r<1000; r+=1)
print r
endloop
I ask
- if somebody can suggest my a different option to slow down the script
because my way lengtens too much the output script.
- do you have some others suggestions or experiences?
Knowlegde to share: finding the tickers of major stock exchange
indexes is not easy. Now I got them, so if somebody wants to share
these lists is welcome.
Regards
Guido
8 years, 4 months
Disregard: Boolean and / or in if-condtion (for example)
by Jan Tille
Hello again,
I have found the appropriate section in the command reference under 'genr'
The available Boolean operators are (again, in order of precedence): ! (negation), && (logical AND), || (logical OR), >, <, =, >= (greater than or equal), <= (less than or equal) and != (not equal). The Boolean operators can be used in constructing dummy variables: for instance (x > 10) returns 1 if x > 10, 0 otherwise.
Sorry to bother you.
Jan
Von: Plus.line MailSystem [mailto:cyrus@mailer.plusline.de] Im Auftrag von Jan Tille
Gesendet: Freitag, 9. September 2016 08:45
An: Gretl list <gretl-users(a)lists.wfu.edu>
Betreff: [Gretl-users] Boolean and / or in if-condtion (for example)
Dear list members,
I know my post is a consequence of my very modest programming skills, however, I think, others users might encounter this problem as well.
I was trying to set up an if-command:
if [condtion 1] = True and [condition 2] = True than
do stuff
endif
In the first place, I used 'and' literally - I have to admit, that my first experience with if-conditions are from Excel-VBA.
This of course produced an error-message.
It took me while to figure out the solution. I remembered an R-tutorial which dealt with Boolean operators when I read the following post:
http://lists.wfu.edu/pipermail/gretl-devel/2007-December/000714.html
And most likely, my fault was to use the wrong operator 'and' instead of '&&'.
Maybe I have missed it in the user guide, but it might be helpful, to put in a table that deals with logical operators
&&, !, ||,etc. like
true && true is true
!true && false is true
Maybe this is clear to anyone else, than you can of course disregard my post.
Best regards
Jan
8 years, 4 months
Boolean and / or in if-condtion (for example)
by Jan Tille
Dear list members,
I know my post is a consequence of my very modest programming skills, however, I think, others users might encounter this problem as well.
I was trying to set up an if-command:
if [condtion 1] = True and [condition 2] = True than
do stuff
endif
In the first place, I used 'and' literally - I have to admit, that my first experience with if-conditions are from Excel-VBA.
This of course produced an error-message.
It took me while to figure out the solution. I remembered an R-tutorial which dealt with Boolean operators when I read the following post:
http://lists.wfu.edu/pipermail/gretl-devel/2007-December/000714.html
And most likely, my fault was to use the wrong operator 'and' instead of '&&'.
Maybe I have missed it in the user guide, but it might be helpful, to put in a table that deals with logical operators
&&, !, ||,etc. like
true && true is true
!true && false is true
Maybe this is clear to anyone else, than you can of course disregard my post.
Best regards
Jan
8 years, 4 months