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
5 years, 11 months
boxplot accuracy
by Allin Cottrell
Responding to Frederik's posting at
http://lists.wfu.edu/pipermail/gretl-users/2017-December/012814.html
"Sometimes the candlebars pretend values which do not exist. I.e.,
if the IQR *1.5 data does not exist (which can happen - it happens
to me), the boxplot gives a false impression."
Please try a current gretl snapshot. This was a known issue but we
believe it's now fixed. In the current Changelog we have:
Boxplots: fix for incorrect extent of "whiskers" in some cases
Allin
6 years, 8 months
bug? with string substitution
by Summers, Peter
Hi all,
I was revisiting some code I wrote a few years ago, and came across what is at least changed (and unexpected) behavior. I have a script that loops over various numbers of possible structural breaks, and does some MCMC sampling for each value. I want to write the mcmc draws to separate data sets labeled by the number of breaks.
Here's what I originally had:
<hansl>
loop ii=1..breaks --quiet
Nbreaks = ii-1
# do a bunch of stuff
loop draws = 1..ndraws -quiet -progressive
# Do MCMC stuff
rhohat = (draw from posterior)
# now save the draws
sprintf fname "rho_%d.gdt", nbreaks
store "@fname" rhohat
endloop
endloop
</hansl>
This worked fine for me when I wrote it. However currently with the latest Windows snapshot, after the first time through the loop, gretl stores successive data sets under the name "@fname.gdt". The string is being updated properly, but not parsed by the store command. If I insert the line
blah = "@fname"
between the sprintf and store commands, everything works fine.
Best,
Peter
[High Point University logo]
Dr. Peter M. Summers |
One University Parkway, High Point, NC 27268
Office: 336-841-9650 | Department of Economics
Choose to be extraordinary!(r)
[Facebook logo]<https://www.facebook.com/HighPointU>[Twitter logo]<https://twitter.com/HighPointU>[Instagram logo]<http://instagram.com/highpointu>[LinkedIn logo]<https://www.linkedin.com/school/28206>
6 years, 9 months
foreach vs for with list
by Schaff, Frederik
Hi there,
why are those not equivalent? I.e., the foreach (which is more concise) does not work as (I) expected. Is there a tweak to make it work?
<hansl>
open denmark.gdt -q
list ls = 1 4
matrices M = null
loop foreach l ls
matrix temp = l
colnames(temp,varname(l))
M+=temp
endloop
matrices M2 = null
loop for s=1..nelem(ls)
matrix temp = ls[s]
colnames(temp,varname(ls[s]))
M2 += temp
endloop
?M
?M2
</hansl>
Thanks
Frederik
6 years, 9 months
LAD rolling regression
by Filipe Rodrigues da Costa
Hi all,
I'm trying to implement a rolling regression using the following
specification:
loop r = 1 .. rolls
loop foreach i share
if sum(missing(share.$i)) == 0
lad share.$i const index
series beta.$i[$t2] = $coeff[2]
endif
endloop
if r<rolls
smpl +step +step
endif
endloop
It basically works well with OLS, but not with LAD. Strangely, the
script output hangs and doesn't end and I have to force quit the
program. Any idea why the specification doesn't work with LAD?
Thanks in advance,
--
Filipe Rodrigues da Costa
Send me an email to: filipe(a)pobox.io
Reach me through Telegram at: https://t.me/rodriguesdacosta
6 years, 9 months
gnuplot: rowstacked histogram over time
by Artur Tarassow
Dear all,
I know this is not the gnuplot forum but I hope that somebody knows how
to solve this using gretl + gnuplot (v. 5 patchlevel 5).
I want to plot a stacked barplot over time by providing the matrix 'mat'
(rows=Time, cols=variables) and a vector 'xmat'. xmat is based on the
$obsdate command holding daily dates in the format YYYYMMDD. My
objective is to handle date strings on the x-axis correctly. But this
drives me nuts...
As you will see, for the moment I deactivated everything related to time
and its formatting. I also took Jack's function for plotting the
historical decomposition based on the SVAR package as a role model but
somehow this doesn't work for me.
I attached the function plus an example which results in the error:
<gnuplot>
plot '-' using 1:($2), '-' using 1:($2)
^
"/home/at/.gretl/gpttmp.DjR2By", line 25: Too many columns in using
specification
*** error in function stackplot, line 70
</gnuplot>
Btw, do we have a function by retrieving the seconds since the Unix
epoch (1970-01-01, 00:00 UTC). I am just curious as gnuplot can handle
this time format
(http://www.phy.ntnu.edu.tw/demolab/html.php?html=doc/gnuplot-doc/html/tim...).
Thanks in advance,
Artur
6 years, 9 months
new GUI convenience: index series
by Allin Cottrell
In git and snapshots there's a new GUI convenience: point-and-click
construction of 100-based indices of selected time series.
It's not rocket science to construct such series via scripting or
console, but I wanted this for classroom use -- when using gretl for
displaying data in a macroeconomics class, for example.
Case in point: From a blank slate, open the fedstl database and
import the series nicur (National Income), wascur (Wages and
Salaries) and cpatax (Corporate profits after tax). Set the sample
range to start in 2000:1. Swipe across the 3 series, right click,
and choose "Add index values". Then swipe across the three newly
created "i_*" index series, right click and do "Time series plot"
(on a single graph).
You can immediately see why US corporations are in great need of a
tax cut... not!
Allin
6 years, 9 months
Function package Robinson.gfn (semiparametric)
by Sven Schreiber
Dear all,
due to certain issues the function package "Robinson" for doing some
semiparametric estimation is going to be removed from the package server
for now. If you are using that package, please keep a local copy for
yourself.
(Also, if you happen to be such a user, perhaps you'd like to help to
resolve the issues. You can contact me on- or off-list in that case.)
As a reminder, ch. 36 of the guide has information about non-parametric
methods in gretl. Some semi-parametric methods such as the Robinson
stuff can be performed with a combination of parametric and
non-parametric estimation steps.
Have a good weekend,
Sven
6 years, 9 months
boxplot - candlebars "suggestive"; heatmap
by Schaff, Frederik
Hello,
sometimes the candlebars pretend values which do not exist. I.e., if the IQR *1.5 data does not exist (which can happen - it happens to me), the boxplot gives a false impression. Is there a good way to deal with it? Or is there, perhaps, a way to plot a jitter instead (for low enough amount of data), like here: https://i.stack.imgur.com/yD7DP.png ?
Frederik
6 years, 9 months
Percentage changes via the GUI
by Allin Cottrell
This is a belated response to Ioannis in
http://lists.wfu.edu/pipermail/gretl-users/2017-November/012785.html
<quote>
(A) Can we enlarge the option "Percentage change of selected
variable" in the "Add" menu to
"Percentage change of selected variable_s_" ? (as is the case for
most other options)
(B) Can we introduce log changes as well in the "Add" menu
"Percentage change of selected variable(s)" option, for example, by
enlarging the window in the percentage changes?
100*log(Yt/Yt(-1), monthly (etc depending on frequency data)
12*100*log(Yt/Yt(-1)) for %m-o-m annualized (etc depending on
frequency data)
100*log(Yt/Yt(-12)) for %y-o-y (etc depending on frequency data)
It is very convenient (especially for teaching purposes) instead of
log from the menu and then multiplying by 100 or 12*100 and so on.
</quote>
OK, that's now in git and snapshots. When defining a percentage
change for a single variable you're asked to choose a name yourself;
when multiple variables are selected the names are auto-generated as
pc_<varname>.
Allin
6 years, 9 months