On Sun, 27 Mar 2011, Grzegorz Konat wrote:
Dear All,
I wonder, if there's any way to plot final error variance decomposition (FEVD)
output, produced after VAR or
VECM, in gretl?
At the moment, only with a little scripting. Here's an example, which I'm
sure you can adapt to your needs quite easily.
<script>
function matrix SVMA(matrix comp, matrix Sigma, scalar horizon)
scalar n = rows(Sigma)
scalar np = rows(comp)
matrix K = cholesky(Sigma)
matrix C = K
matrix tmp = I(np)
matrix ret = zeros(horizon, n*n)
loop for i=1..horizon --quiet
ret[i,] = vec(C)'
tmp = comp * tmp
C = tmp[1:n,1:n] * K
end loop
return ret
end function
function matrix FEVD(matrix SVMA)
scalar n2 = cols(SVMA)
scalar n = sqrt(n2)
scalar h = rows(SVMA)
matrix ret = zeros(h, n2)
matrix cC = zeros(n, n)
loop for i=1..h --quiet
matrix C = mshape(SVMA[i,], n, n)
matrix tmp = C.*C
cC += tmp
tmp = cC ./ sumr(cC)
ret[i,] = vec(tmp')'
end loop
return (seq(0,h-1)') ~ ret
end function
# ------- main ---------------------------------------------
open sw_ch14.gdt
series infl = 400*ldiff(PUNEW)
var 4 LHUR infl
X = SVMA($compan, $sigma, 20)
fevd = FEVD(X)
gnuplot 2 3 1 --matrix=fevd --output=display --with-lines
gnuplot 4 5 1 --matrix=fevd --output=display --with-lines
</script>
So far, the only way I know is to export data to GNU R and plot FEVD
there. This approach, however, has its disadvantages, as one has to
estimate the whole system in R first and R's estimates often differ
significantly from those obtained with gretl.
This is more worrying. The same model should produce the same estimates
both in gretl and R. Could you provide us with an example?
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti