On Tue, 23 Feb 2010, Sven Schreiber wrote:Hi all,

Artur T. schrieb:

Hello gretl community ;-)

I would like to ask whether there are any plans to incorporate

generalized impulse response functions into VAR analysis; based on the

papers by:

1. Koop, G., Pesaran, M. H. and S. M. Potter (1996), “Impulse Response

Analysis in Nonlinear Multivariate Models”, Journal of Econometrics, 74,

119–147.

and maybe

2. Pesaran, M. H. and Y. Shin (1998), “Generalized Impulse Response

Analysis in Linear Multivariate Models”, Economics Letters, 58, 17–29.)

Or maybe anyone has written some function for it? I have no idea how

difficult it is to implement this feature, but I think it might be

worthy if the programming effort is not too big and the demand for it

sufficient.

IIRC the "GIRFs" are easy to obtain. If you want the GIRF for the i-th

variable, you just reorder the variables in the VAR such that the i-th

variable is in the first (or last? I always mix it up...) position, and

then you apply the classic Cholesky decomp. So if you want the GIRFs for

all n variables, you repeat this trick n times.

That's why IMHO the GIRFs are a little over-hyped, but OTOH I don't see

them in papers that much, so maybe the hype isn't real.

So this looks like a very good case for a user-contributed function

package. Artur, I'm sure you could do it yourself!

I agree with Sven. The only thing I want to add is that I'm working on a substantially revised version of my SVAR package: the code is almost ready (only the cointegrated case is missing), the docs are a bit behind. I'll post a link when it's ready: by studying my code, you'll probably be able to write a function for GIRFs with relatively little effort.

Riccardo (Jack) Lucchetti

Dipartimento di Economia

Università Politecnica delle Marche

r.lucchetti@univpm.it

http://www.econ.univpm.it/lucchetti

_______________________________________________ Gretl-users mailing list Gretl-users@lists.wfu.edu http://lists.wfu.edu/mailman/listinfo/gretl-users

I found some time to improve my gretl programming skills a little bit and improved the function for the GIRF. I've got still some issues with it. Maybe somebody is interested to help me with it...

1. The results seem to be ok from my perspective. Since I cannot compare them at the moment, maybe someone is interested in checking the code.

2. I would like to add an output describing which is the shock variable and which are the responses for the generated matrix. Something like:

Responses of the respective variables to a shock in Variable 1.

Period Variable 1 Variable 2 ...

1 0.03 0.9

2. I wrote the function in such a way that it estimates a VAR system and then conducts the GIRF. Since you can have all those additional options like --nc --trend --robust and so on, the function would be quite big to consider all those cases. So, is it maybe reasonable to call the function after one has estimated the VAR by the conventional way and then calling the function?

3. I also would like to improve the plotting. I want to plot the responses of all variables to a specific shock within one graph. For example, if I have three variables which are shocked, the plot command must be "gnuplot 1 2 3 --time-series..." where 1 2 3 denote the corresponding columns of the response matrix. Is there a way to generalize this in such a way that one can type in the corresponding numbers of coulumns one wants to plot in the "function-gui" or just to plot all columns which equals the number of endogenous variables?

The code is here:

---------------------------------------------------------------

function void Generalized_IRF (list Y "List of variables", scalar order "VAR order", scalar rk "cointegration rank", scalar horizon "Forecast horizon")

if rk = 0

var order Y

else

vecm order rk Y

endif

matrix A = $compan

matrix D= zeros(nelem(Y)*order, nelem(Y))

D[1:nelem(Y),] = $sigma

scalar eq= nelem(Y)

loop i=1..eq --quiet

matrix A$i=A

endloop

loop i=1..eq --quiet

matrix response$i = zeros(horizon,horizon)

scalar M = D[$i,$i]

matrix O = D[,$i]

response$i[1] = transp(M^(-0.5)*transp(A$i)^0*O) #IRF for the first period

loop j=3..horizon --quie

A$j =A^(j-1)

E = M^(-0.5)*A$j*O #Calculate the GIRF

response$i[j-1] = transp(E[1:eq,])

response$i=response$i[1:horizon-1,] #Delete last row because it is otherwise '0'

endloop

response$i = response$i[,1:nelem(Y)]

endloop

#Print the results

loop i=1..eq --quiet

print response$i

endloop

#Plotting. Unfortunately, one has manually to set up the columns to plot, e.g. gnuplot 1 2 .. --time-series

loop i=1..eq --quiet

gnuplot 1 2 --time-series --with-lines --matrix=response$i --output=display { set title 'Response of variable $i to the respective shock';}

endloop

end function

---------------------------------------------------------------

Best wishes,

Artur