renaming series in loops
by Allin Cottrell
This is a propos the thread started by Javier Sansa at
http://lists.wfu.edu/pipermail/gretl-users/2016-March/011708.html
I have now re-enabled the "rename" command in loops, thus reverting
to the situation as of the 2015a release.
This is because I've come up with a method that I'm comfortable
with, for ensuring that renaming doesn't cause problems. Instead of
trying to figure out what cases of "rename" are problematic and what
cases OK, this is the approach:
(1) You can use "rename" at will, but
(2) we check if a loop (or in the general case, a stack of nested
loops) involves any cases of "rename" (quite easy), and if so
(3) we temporarily disable the particular loop-optimization which is
vulnerable to renaming.
Here's a little illustration:
<hansl>
open data4-1
loop i=1..6 -q
x = max(price) / max(sqft)
printf "x = %g\n", x
rename sqft tmp
rename price sqft
rename tmp price
endloop
Since this loop swaps the numerical content associated with the
identifiers "price" and "sqft", the scalar x should take on
different values on odd- and even-numbered iterations. And it does.
The price is that we have to look up the ID numbers (positions
within the dataset) of "price" and "sqft" on each iteration. If we
were sure there was no renaming going on, we would look up the ID
numbers once and reuse that information on subsequent iterations.
Note that (since we're not trying to be "too clever" here) _any_
instance of renaming in a loop means that _all_ series ID numbers
will be looked up anew on each iteration of the loop, for safety's
sake. But that's not really a big deal unless you're running a
potentially quite time-consuming script.
Allin
8 years, 9 months
Renaming variables not allowed within a loop
by Javier Sansa
I have just tried the last snapshot and I have run an old script that
renames a variable within a loop
Something like:
loop for i = 1..j --quiet
...
rename T$i @a
...
end loop
and I get the message
"Sorry, this command is not available in loop mode"
"Error executing script: halting"
Using rename within a loop was allowed up to (and including) version
2016a, which leads me to question: Is it a new feature or a bug?
For your information I am using gretl 64 on a windows-7 Pro machine.
Otherwise the program (new snapshot) does a wonderful job.
Regards,
Javier Sansa
8 years, 10 months
automated frequency histograms plotting and saving
by Schaff, Frederik
Hello,
I was wondering if there exists an (undocumented) option to save freq. histograms to the disk as, say .png file. I can use the" --show-plot" option in a loop and then manually save the figures thus created (even save them as icon and manipulate them). But is there a way to save them to a file like it is possible with scatters and boxplots? I.e. something like an "output=" option and perhaps even a way to pass additional arguments via { set ... ; } ?
Many thanks as always
Frederik Schaff
8 years, 10 months
Use of filter
by Artur T.
Dear all,
I am playing around (again) with the filter() function. I took a simple
example similar to the one in the gretl guide, and I am wondering why
the use of the filter() function for series "y2" doesn't yield the same
results as for series "y" even though the weight for the random term "u"
is set to unity. Am I missing anything? Actually the same happens when
trying to replicate the ARMA(1,1) example in the guide.
<hansl>
clear
set echo off
set messages off
set seed 1234
nulldata 20
matrix a = muniform(2,1) # AR
series u = normal()
series y = 0
# Simulate AR(2) process
list Ly = y(-1 to -2)
y = lincomb(Ly,a) + u # 1st version
# Use filter() now
series y2 = filter(u, 1, a)
print y y2 -o # Not the same
</hansl>
Best,
Artur
8 years, 10 months
Mysterious error with a simple subtraction
by Sven Schreiber
Hi,
I've run into a strange error which I'm sure is a bug, at the very least
because the error message is absolutely uninformative:
<output>
? series tully = tul2an – tucpn
Fehler bei Skriptausführung: Stopp
</output>
(Re-translated it just means "error while running script: stop".)
As you can see the operation is a simple subtraction. The series tul2an
and tucpn do exist, gretl happily displays their summaries just before that.
The context is a pretty large panel dataset with lots of missings (but
temporarily declaring the data as a large undated cross-section didn't
change anything). The dataset is not yet subsampled at that stage. I've
tried all kinds of variations with zeromiss() and misszero() but that
didn't help. Unfortunately I cannot provide the (confidential) data.
The version is now the latest snapshot in Win7 64bit, and it also
happened with a snapshot from a month ago.
Any ideas for workarounds, further things to try and test?
Thanks,
sven
8 years, 10 months
two (strange) bugs (?) -- open & restrict+boxplot+factorize
by Schaff, Frederik
Hi there,
I have encountered two kinds of strange bugs with gretl 2015-10-16 x86_64 on Windows:
1.) Opening a file like the attached one with a "just launched" gretl instance will result in automatically substituting the string variables with IDs. However, starting gretl with a script which opens the file with the --preserve option works fine. And, after this was done first within the current gretl instance, if one "selects" open from the menu, it works also as-if the "preserve" option is turned on. Cost me a bit of time to get to it...
2.) The same file as attached, opened such that the string variables "name" from t1 to t3 are there. Then restrict the sample such that "t2" is not included. The factorized boxplot will have as x-tics t1 , t2. The same is true if you take the "--permanent" option. This made me more of a headache until I got there ;)
I read that there are some bugs in the recent non-release gretl version but I do not know if this was already known.
The example file and the example scripts are attached.
PS: Is there an easy way to pipe individual varnames for the x-tics in a boxplot to gnuplot via the {} command? And, why can I do something like "Values = (Values ==1 ? 10 : Values)" but not "Name = (Name == 't1' ? 'uiui' : Name)"? Is there an alternative to do so which I am not aware of?
Regards and many thanks
Frederik
------------
Frederik Schaff, Dipl.-Volkswirt
FernUniversität in Hagen
Fakultät für Wirtschaftswissenschaft
Lehrstuhl für VWL, insb. Wirtschaftstheorie
Universitätsstraße 11 (TGZ)
58097 Hagen
Telefon: +49 (0) 2331 987-4454
E-Mail: Frederik.Schaff(a)FernUni-Hagen.de
http://www.fernuni-hagen.de/wirtschaftstheorie/team/frederik.schaff.shtml
8 years, 10 months
Granger causality test in Gretl
by 何晨蕾
Sorry to bother you. I am a student from Nanjing Agriculture University China.
For my dissertation purpose I need to run Granger Causality tests using Gretl. I am using time series data, would you mind giving me some advice on the following questions:
For everybody knows, Granger test is conducted in the framework of a vector autoregression (VAR).But Granger causality tests are not provided among the menu in gretl when I estimated a VAR, so how to run Granger Causality in Gretl?
8 years, 10 months
gretl 2016a strange crash
by Pedro Bação
Hello,
I now detected the following problem. The script below runs in gretl
1.9.11, but will cause gretl 2016a to crash (I am using ubuntu 12.04, gretl
2016a is in a virtualbox).
nulldata 10
function series f1(series z)
series s=1
loop i=1..1
s[1]=0
endloop
return s
end function
function scalar f2(matrix *my,matrix *ma)
series z=1
series f=f1(z)
return 1
end function
series y=0
matrix my=ones(10,1)
matrix par=1
scalar a=BFGSmax(par,f2(&my,&par))
series yy=0
series x=f1(y)
Oddly, if I add a line between the final two and that new line defines a
series (e.g. series yy=0), it will not crash. Additionally, if I comment
out s[1]=0 in f1 or comment out loop i=1..1 and the corresponding endloop,
it will also not crash.
Thanks,
Pedro
8 years, 10 months
convert matrix to series
by Pedro Bação
Hello,
If I run the script
nulldata 10
smpl 6 10
series y=t
matrix my=y
smpl 1 5
series yy=my
print yy
in gretl 1.9.11 I get
gretl version 1.9.11
Current session: 2016-03-01 18:35
? nulldata 10
periodicity: 1, maxobs: 10
observations range: 1-10
? smpl 6 10
Full data range: 1 - 10 (n = 10)
Current sample: 6 - 10 (n = 5)
? series y=t
Generated series y (ID 2)
? matrix my=y
Generated matrix my
? smpl 1 5
Full data range: 1 - 10 (n = 10)
Current sample: 1 - 5 (n = 5)
? series yy=my
Generated series yy (ID 3)
? print yy
Current sample: 1 - 5 (n = 5)
6.00000 7.00000 8.00000 9.00000 10.0000
But if I run the same script in Gretl 2016a I get:
gretl version 2016a
Current session: 2016-03-01 18:36
? nulldata 10
periodicity: 1, maxobs: 10
observations range: 1 to 10
? smpl 6 10
Full data range: 1 - 10 (n = 10)
Current sample: 6 - 10 (n = 5)
? series y=t
Generated series y (ID 2)
? matrix my=y
Generated matrix my
? smpl 1 5
Full data range: 1 - 10 (n = 10)
Current sample: 1 - 5 (n = 5)
? series yy=my
Generated series yy (ID 3)
? print yy
Current sample: 1 - 5 (n = 0)
NA NA NA NA NA
In this context, is there a quick way of making the first 5 observations of
series yy to equal the content of matrix my, like in older versions of
Gretl?
Thanks,
Pedro
8 years, 10 months