Hi,
thanks for the feedback Matthieu. It was very helpful. I hope your qualifying exams went well!
So, after some time I took another look at my function. Unfortunately there was a (really stupid) mistake in it. In my first version I shocked the residuals of the reduced form equation, which, of course, doesn't make much sense. I don't know how I could overlook that...
So I had to change my code. The residuals are now transformed into structural errors by the inverse of a Cholesky factorization (as suggested by Koop et al (1996)). After adding the initial shock , the errors are transformed back by the Cholesky factor and used in the simulation.
Furthermore, in the first version I bootstraped the residuals one by one. However, most authors argue that the shocks are jointly distributed. Therefore one should bootstrap vectors of size k, where k is the number of endog. variables. I also changed that.
Lastly I changed the algorithm a little bit: While some authors take each observations as a history (like I did in the first version), others take samples within the regimes (with replacement). I think the second approach is more useful, because the number of histories within each regime are equalized by this approach. in the old approach we could easily end up in a situation where one regime has only a few observations, which reduces the number of histories drastically. This also reduces the quality of the simulations.
My new approach is based on Caggiano et al (see attachment), although they are not estimating a threshold VAR. But the GIRF algorithm shouldn't be affected by that.
If someone is interested in Generalized Impulse Response functions and wants to give me some feedback, I would appreciate it. Unfortunately I wasn't able to reproduce any examples yet (I want to try that soon).
The R-file in the attachment contains a simple example and three functions. Two of them are used for calculating the GIRF (the second function is just called by the first one internally). The last function plots the responses (I just wrote this one today. So it's very experimental).
Best,
Alex