Hamilton trend-cycle decomposition
by Riccardo (Jack) Lucchetti

Hi all,
yesterday, after having taught my students the HP decomposition, I
wondered if I should also tell them that one of the greatest time-series
econometricians on Earth recently wrote a rather scathing paper entitled
"Why You Should Never Use the Hodrick-Prescott Filter", where he proposes
a simple alternative.
So this morning I rustled up a little script with Hamilton's filter. Here
it is:
<hansl>
function series hamcycle(series y, bool do_plot[1], string title[null])
h0 = 2 * $pd
h1 = h0 + 4
list PROJ = y(-h0 to -h1)
ols y 0 PROJ -q
# ht = $yhat
hc = $uhat
if do_plot
if !exists(title)
title = argname(y)
endif
print title
diff8 = y - y(-h0)
setinfo diff8 --graph-name="Random walk"
setinfo hc --graph-name="Regression"
list PLT = diff8 hc
plot PLT
options time-series with-lines
literal set linetype 1 lc rgb "#ff0000"
literal set linetype 2 lc rgb "#000000"
literal set key top right
printf "set title '%s'", title
end plot --output=display
endif
return hc
end function
# example
nulldata 300
setobs 4 1947:1
open fedstl.bin
data gdpc1 expgsc1 pcecc96
list Y = gdpc1 expgsc1 pcecc96
LY = logs(Y)
strings Titles = strsplit("GDP Exports Consumption")
k = 1
# reproduce part of figure 6
loop foreach i LY --quiet
hc = hamcycle($i*100,,Titles[k++])
endloop
</hansl>
Should we turn this into a function 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 months, 2 weeks

Count consecutive observations
by F.R.Costa

I guys,hope you're all well,
I have a very quick question. I am working with stock market data. Let's say I have price observations for stock X. I want to exclude stock X from my data if it doesn't have at least 24 consecutive observations. Is there any simple command able to retrieve a consecutive count of observations. $nobs would give a total count, but is there a way to take account of this?
Thanks in advance
F.R.Costa
--
Securely sent with Tutanota. Get your own encrypted, ad-free mailbox:
https://tutanota.com
11 months, 1 week

Re: Fwd: FIML estimation in single equation regression
by José Perles

Thanks Sven for your fast response.
In fact I have a sample with lots of missing data. From 207 observations I get with OLS command an effective sample size of 76.
I have seen that FIML would be a solution and some perform the analysis for example in Stata using “sem” command (method=mlmv).
I would know of it is possible to replicate the Stata result in Gretl.
Thanks again
José
Enviado desde mi iPhone
> El 30 abr 2020, a las 17:53, Sven Schreiber <svetosch(a)gmx.net> escribió:
>
> Am 30.04.2020 um 16:53 schrieb JOSE FRANCISCO PERLES RIBES:
>> Dear team:
>> There is an implementation of FIML estimation in the context of single
>> equation regression in Gretl?.
>> I have seen that Stata and other R functions performs this kind of
>> analysis using SEM capabilities as a workaround to deal with missing
>> data. Also I have found that there is an implementation in Gretl for the
>> case of Systems of Equations....
>
> Hello José, since OLS is also ML for a linear single equation I guess
> this is not what you mean. You mention missing data, is that what you're
> dealing with? It would be useful if you could describe in more detail
> what problem you're trying to solve.
>
> cheers
> sven
> _______________________________________________
> Gretl-users mailing list -- gretl-users(a)gretlml.univpm.it
> To unsubscribe send an email to gretl-users-leave(a)gretlml.univpm.it
> Website: https://gretlml.univpm.it/postorius/lists/gretl-users.gretlml.univpm.it/
11 months, 2 weeks

Clarification on Gauss-Legendre quadrature
by Alecos Papadopoulos

Maybe this is really a clarification on the theory, not on what gretl
does, but I will start by asking here.
Gretl gives weights and nodes for Gauss-Legendre quadrature for
arbitrary finite lower and upper limits of integration, not only the
default (-1,1).
Suppose I have a definite integral \int f(x) dx, with limits (a,b). I
ask Gretl for help through the quadtabe command, say for five nodes
matrix GLegm = quadtable (5,2, a,b) .
gretl obliges, and I get my nodes and my weights. Should I then also
make the transformation y = 2*(x-a)/(b-a) - 1, and evaluate the
integrand by [(b-a)/2]*SUM {w_i* f[a+(y_i+1)*(b-a)/2]},
where w_i are the weights I got and y_i the nodes I got,
or should I evaluate the integrand by SUM {w_i f(x_i)}, where here the
nodes I got interval are represented by x_i?
I ended up laughing with how confused this one has got me. The confusion
stems from the question "since I adjust the nodes and weights to the
actual interval (a,b), why should I also adjust the integrand?" But I
remember reading a tutorial on the matter, and it appeared to suggest
that we should do both: get weights and nodes for the (a,b) interval
/and /apply the transformation.
Any suggestions?
--
Alecos Papadopoulos PhD
Athens University of Economics and Business
web: alecospapadopoulos.wordpress.com/
skype:alecos.papadopoulos
11 months, 3 weeks

Fwd: FIML estimation in single equation regression
by JOSE FRANCISCO PERLES RIBES

Dear team:
There is an implementation of FIML estimation in the context of single
equation regression in Gretl?.
I have seen that Stata and other R functions performs this kind of analysis
using SEM capabilities as a workaround to deal with missing data. Also I
have found that there is an implementation in Gretl for the case of Systems
of Equations....
Thanks in advance and sorry for any inconvenience.
José Perles
University of Alicante
11 months, 3 weeks

Found it by luck (the odd typo).
by Ioannis A. Venetis

Hi all,
I copy - paste (copy-pasted or copied-pasted ? :))
Listing 9.1: Periodogram via the Fourier transform for the
gretl-guide.pdf
At least in my computer the transpose symbol is not the expected one by
gretl so it returns the following error.
<script output>
Unexpected byte 0xe2
C:\Program Files\gretl\write.chk: Permission denied
Couldn't write to 'C:\Program Files\gretl\': gretl will not work
properly!
C:\Users\Venetis\AppData\Roaming\gretl\gretl.pid: No such file or
directory
C:\Users\Venetis\AppData\Roaming\gretl\gretl.pid: No such file or
directory
Error executing script: halting
> omega = seq(1,($nobs/2))' .* (2*$pi/$nobs)
</ script output>
I know it seems the same but apparently it is not.
omega = seq(1,($nobs/2))' .* (2*$pi/$nobs)
Best,
Yiannis
11 months, 3 weeks

print .... -o is not listed in gretl:command reference or elsewhere
by Ioannis A. Venetis

Hi all,
I saw Jack's last hansl code, in particular, line
print x streak -o
Apparently it does what
print x streak --byobs
would do. But the option -o is not listed either in gretl:command
reference or gretl-ref.pdf.
It appears however in a number of places in the gretl-guide.pdf (in
listings, e.g Listing 14.1: Usage of interaction lists, page 117)
Best,
Yiannis
11 months, 3 weeks

On manageable matrix dimenisons
by Alecos Papadopoulos

I have a question for more experienced users and the guardians of gretl.
I am about to go into Markov Chain Monte Carlo simulations and an
acceptance/rejection algorithm of the generated values. This would
require something like 200,000 loop runs, from which say something like
100,000 will be accepted and should be stored. The number of parameters
is 32.
Up to now with smaller simulations, I used to store such values in
matrix objects, and then turn them into series objects. But now I am
looking at a 100,000 X 32 matrix, or at best at 32 vectors of 100,000 X
1 dimension, and I was wondering whether such a large row dimension will
create problems of speed or any other kind of problems.
Any suggestion on that?
--
Alecos Papadopoulos PhD
Athens University of Economics and Business
web: alecospapadopoulos.wordpress.com/
skype:alecos.papadopoulos
11 months, 3 weeks

Sign function in gretl
by Alecos Papadopoulos

I thought we had a sign function in gretl but I cannot find it
(returning 1 if positive -1 if negative, 0 if zero)
The need arose in estimating AR(1) procecess with a near-unit root.
Following Hamilton's advise in order to avoid crashing the iterative
algorithm, I reparametrize the autoregressive coefficient rho by
rho = lambda / (1 + abs(lambda)
Then
lambda = rho / (1- sgn{rho} *rho).
Certainly one can write
sign(rho) = (1- (rho==0) )* (1- 2*(rho <0)),
or something more efficient,
but the sign seems pretty fundamental to be an expression or a
user-defined function. Is it hidden somewhere? :)
--
Alecos Papadopoulos PhD
Athens University of Economics and Business
web: alecospapadopoulos.wordpress.com/
skype:alecos.papadopoulos
11 months, 3 weeks