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>