On Wed, 10 Oct 2012, Ignacio Diaz-Emparanza wrote:
When I run the attached script, it seems the function is correctly
generating
the filtered series, and they are available from the command line, but they
don't appear in the main window, so I cannot make the graphs from the menus.
Some time ago this was different.
This is on Ubuntu linux 12.04 and with gretl 1.9.9cvs downloaded today, but I
also tried with a version from a month ago with the same problem. So I think
the question about the length of the names is not the problem here.
Totally unrelated to your problem, but still helpful, I hope: your
function could be made a bit more compact and possibly slightly more
efficient by using vectors instead of loops where possible:
<hansl>
function list seasfSTB(const series *y)
string yn=argname(y)
#scalar pd=$pd
scalar pd1=$pd-1
scalar fpd2=floor($pd/2)
scalar pd2=$pd/2
scalar s21 = (pd2==fpd2) ? floor($pd/2)-1 : floor($pd/2)
matrix b0 = ones($pd,1)
# all frequencies except zero
series @yn0 = (obs>=$pd) ? filter(y,b0) : NA
if pd2==fpd2
matrix b2 = cos($pi * seq(1,$pd))
series @ynpi = (obs>=$pd) ? filter(y,b2) : NA
list fil = @yn0(-1) @ynpi(-1)
else
list fil = @yn0(-1)
endif
loop j=1..s21 --quiet
scalar w = 2*$pi/$pd * j
matrix frq = seq(1,$pd) * w
series @yna$j=(obs>=$pd) ? -filter(y,cos(frq)) : NA
series @ynb$j=(obs>=$pd) ? filter(y,sin(frq)) : NA
list fil += @yna$j(-1) @ynb$j(-1)
endloop
return fil
end function
</hansl>
Also, you can omit the third argument to filter() if null. Finally, you
may want to start using $pi instead of pi, which will probably be
deprecated in 2.0 (this will only work with CVS, though).
--------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
--------------------------------------------------