Identification of SVARs using heteroskedasticity
by anzervas＠yahoo.com

Dear all (especially Sven and Riccardo),
A recent strand in SVAR literature uses heteroskedasticity to identify the structural shocks - those interested in the topic may read mainly Rigobon (Review of Economics and Statistics 2003), Lanne and Lutkepohl (Journal of Money Credit and Banking 2008) and / or Bacchiocchi and Fanelli (Oxford Bulletin of Economics and Statistics 2015). If one has 2 variance - covariance matrices, there is no need to add zero or other restrictions to identify the structural matrices A or B.
It is not clear to me how one can implement this on Gretl. Especially I did not find any way to implement this method using matrix operations, and the only possible way seems to employ an optimization algorithm. I have tried it, but in vain. Below I attach a script, formulated like in Lanne - Lutkepohl (2008) but it is not working properly. Especially, I cannot understand how to make the procedure go to a solution that respects the equality S1 = B*B'.
In addition, Rigobon (op. cit.) mentions that he uses GMM to solve the problem. I do not know if this is feasible in Gretl, but even if it is, it is not clear to me how one could write the GMM block to do it (though the manual mentions that one may use only matrices in GMM block equations).
Any suggestions / corrections are welcome. This also seems be a good functionality to add to the SVAR package (in addition to add AB model functionality to VECMs, for completeness purposes).
Kind regards,
Andreas
<begin hansl scipt>
set verbose off
# set lbfgs on
set bfgs_maxiter 50000
set bfgs_toler 0.0000000000000001
function scalar LnL(const matrix param, matrix S1, matrix S2)
A = {param[1],param[2],param[3],param[4]; \
param[5],param[6],param[6],param[8]; \
param[9],param[10],param[11],param[12]; \
param[13],param[14],param[15],param[16]}
L = zeros(rows(S1),cols(S1))
L[1,1] = param[17]
L[2,2] = param[18]
L[3,3] = param[19]
L[4,4] = param[20]
LL0 = -100*0.5*(ln(det(S1)) + tr(S1*inv(S1))) \
-100*0.5*(ln(det(S2)) + tr(S2*inv(S2)))
LLi = -100*0.5*(ln(det(A*A')) + tr(S1*inv(A*A'))) \
-100*0.5*(ln(det(A*L*A')) + tr(S2*inv(A*L*A')))
# dist = abs(LLi - LL0)
dist = maxc(abs((vech(S1)|vech(S2)) - (vech(A*A')|vech(A*L*A'))))
dist
return dist
end function
# structural shocks and matrix
E1 = mnormal(100,4)
E2 = mnormal(100,cols(E1)).*{0.1, 2.5, 0.4, 1.7}
W = 0.1*mrandgen(i, 1, 4, 4, 4)
# reduced form residuals
U1 = E1*W
U2 = E2*W
S1 = U1'U1/rows(U1)
S2 = U2'U2/rows(U2)
# initial parameters
param = 0.1*abs(mnormal(cols(U1)^2+cols(U1),1))
# minimization
ff=BFGSmin(¶m, LnL(param, S1, S2))
# bounds = seq(1,rows(param))'~ones(rows(param),2).*{-20, 20}
# bounds[17,] = {17, 0, 10}
# bounds[18,] = {18, 0, 10}
# bounds[19,] = {19, 0, 10}
# bounds[20,] = {20, 0, 10}
# ffc=BFGScmin(¶m, bounds, LnL(param, S1, S2))
param
B = {param[1],param[2],param[3],param[4]; \
param[5],param[6],param[6],param[8]; \
param[9],param[10],param[11],param[12]; \
param[13],param[14],param[15],param[16]}
L = zeros(rows(S2),cols(S2))
L[1,1] = param[17]
L[2,2] = param[18]
L[3,3] = param[19]
L[4,4] = param[20]
S1b = B*B'
S2b = B*L*B'
# Check that estimations reproduce reduced form covariance matrices and structural matrix
S1
S1b
L
S2
S2b
W
B
<end hansl scipt>
7 months

just a typo - page 161 of gretl guide
by Ioannis A. Venetis

Well not much but since I found it: last paragraph at page 161 of Gretl
User's Guide
from
... to an array if strings.
to
... to an array of strings.
Thanks,
Yiannis
7 months, 4 weeks

Gretl online
by Diego Fernández

Hello,
I need to know if it is possible to run Gretl in an online version
Thanks
--
Diego Fernández
Magister en Economía
Docente Asistente Departamento Economía
Facultad de Ciencias Económicas www.fcea.edu.uy
7 months, 4 weeks

dbnomics: cannot get some ECB data?
by klaus.hasenbach＠web.de

Hello
Gretl with dbnomics works very well for me and I`m very happy with both.
But sometimes it is not possible to retrieve time series which are in
the databank of dbnomics and can be retrieved on their web site correctly.
For instance a regular script "data
ECB/BSI/M.U2.N.R.LRE.X.1.A1.3000.Z01.E" does not work for this time
series in gretl. When I go to the search menu of dbnomics in gretl
instead and try to chart this time series it says "nicht endliche
Werte" what more or less means "not finite values" in english.
I use Windows 10, gretl 2018c or 2019d with dbnomicc 0.2 or 0.35. Any
help? Thank you!
Regards,
Klaus
7 months, 4 weeks

Example code of 'eigensym' and way faster 'eiggen2'
by Ioannis A. Venetis

Running the following script I get a huge difference
timerB = 0.010171000
timerA = 0.22064500
ratio = 21.693540
It does not matter if LOOP2 comes in place of LOOP1.
Also I get eigenvalues in descending order in LOOP2 instead of ascending
as in eigensym but that's not the issue (I guess).
I hope the code has not any silly mistakes.
Thanks for your time anyway.
Yiannis
<\hansl>
clear
set verbose off
mynameisseed = randgen1(i,1000000,10000000)
set seed mynameisseed
set seed #8402212
reps = 1000
matrices AtA = array(reps)
loop i = 1..reps -q
A = mrandgen(i,-5,5,4,4)
AtA[i] = A'A
endloop
# LOOP 2
set stopwatch
loop i = 1..reps -q
matrix V = {}
matrix W = {}
D = eiggen2(AtA[i],&V,&W)
Tmp = mreverse(msortby(Re(D)~Re(V)',1))
D = Tmp[,1]
V = Tmp[,2:]'
# print D
# print V
endloop
timerB = $stopwatch
print timerB
# LOOP 1
set stopwatch
loop i = 1..reps -q
matrix V = {}
matrix W = {}
D = eigensym(AtA[i],&V)
# print D
# print V
endloop
timerA = $stopwatch
print timerA
ratio = timerA/timerB
print ratio
</hansl>
8 months, 1 week

eiggen2(), Re() and Im()
by Allin Cottrell

I'm responding to several recent posts by Sven and Ioannis.
1) I accept Sven's point that "eiggen2" is not a great name for the
revised (to deal with native complex matrices) variant of the old
"eigengen" function. In git, I've now renamed eiggen2() to eigen(),
and revised the doc accordingly. But for the present I've retained
"eiggen2" as an alias since I was concerned about breaking the
ghosts and/or DFM packages.
2) I accept Ioannis's point that the new functions Re() and Im()
might reasonably be applied to real matrices as well as complex
ones. Given real input, Re() would return a copy of the input and
Im() would return an appropriately sized zero matrix. That too is
now in git.
3) I'm not so sure about Sven's suggestion that (if I'm
understanding him right) sqrt(M), for M a real matrix with some
negative elements, should return an appropriate complex matrix. It's
clearly defensible, but it might produce surprising/puzzling results
in some cases so I think it requires further discussion.
Allin
8 months, 2 weeks

A: real matrix, Re(A) and Im(A) possible;
by Ioannis A. Venetis

Hi all,
I understand 'Data types not conformable for operation' but could it be
that if A was a real matrix then Re(A) = A and Im(A) = zeros(.,.) ?
I do not know how difficult that might be.
At the moment it is not possible.
The issue arose as I was experimenting with 'eigensym' and 'eiggen2'.
The latter seems to be way faster than the eigensym for symmetric
matrices (sorting eigenvalues considered). But this is another issue I
will raise with a code example when it's ready.
Yiannis
8 months, 2 weeks

Re: Kalman and MLE issue
by Alecos Papadopoulos

Good afternoon.
I am trying to estimate the parameters of a model that also has latent
state variables, using the Kalman filter and maximum likelihood.
After setting up the filter, which I run and it appears to work fine on
its own (i.e treating the parameters fixed to their initial values), I
follow the example script in p. 313 of User's guide, where the mle
command line is
mle logl = ERR ? NA : kb.llt (where "kb" is the name of the Kalman
bundle)
and inside the mle command we see
ERR = kfilter(&kb)
I wrote the same syntax but using "ksmooth" instead of "kfilter".
I get the message
<<
"llt": no such item
The formula 'logl = ERR ? NA : kb.llt'
produced an error on execution
>>
I tried also to embed the lot into a function, as the example script
does, but I continued to get the same error message.
Any ideas?
--
Alecos Papadopoulos PhD
Athens University of Economics and Business
web: alecospapadopoulos.wordpress.com/
skype:alecos.papadopoulos
8 months, 2 weeks