Gathering multiple IRFs

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Gathering multiple IRFs

Postby nbt » Mon Oct 14, 2013 5:44 pm

Hi,

is there a possibility to repeat one AR(1) shock multiple times in the same model and then plot the the frequency distribution of the highest deviation of a control variable from steady state (like the aggregate IRF)?

Best regards,
nbt
nbt
 
Posts: 7
Joined: Sun Oct 13, 2013 12:12 pm

Re: Gathering multiple IRFs

Postby jpfeifer » Mon Oct 14, 2013 7:54 pm

Note that this only makes sense at higher order. At first order, the IRFs will always be the same due to linearity.
If you want to do this at higher order, it requires you hacking the irf.m function of Dynare. Instead of averaging over different IRFs you need to store the individual draws.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Gathering multiple IRFs

Postby nbt » Tue Oct 15, 2013 2:13 pm

thanks. I just tried doing it by hand, that is simulating the model repeatedly and storing the entry in the oo_/irfs. Why does the shock response always look the same? I thought in each simulation there would be a random shock imposed?

How would you manipulate the irf.m file to store the irfs? It would take me too long to get acquainted with the code in detail, time I havent got :mrgreen: Would really appreciate your help!
nbt
 
Posts: 7
Joined: Sun Oct 13, 2013 12:12 pm

Re: Gathering multiple IRFs

Postby jpfeifer » Tue Oct 22, 2013 10:09 am

No. The concept used is a generalized IRF. At first order, the IRFs will always be the same due to linearity. If you tried higher order, did you use a different seed for generating random shocks (see the manual)?

It should be sufficient to replace
Code: Select all
    for j = 1: replic
        ex1(:,i_exo_var) = randn(long+drop,nxs)*chol_S;
        ex2 = ex1;
        ex2(drop+1,:) = ex2(drop+1,:)+e1';   
        y1 = simult_(temps,dr,ex1,iorder);
        y2 = simult_(temps,dr,ex2,iorder);
        y = y+(y2(:,M_.maximum_lag+drop+1:end)-y1(:,M_.maximum_lag+drop+1:end));
    end
    y=y/replic;

by
Code: Select all
   for j = 1: replic
        ex1(:,i_exo_var) = randn(long+drop,nxs)*chol_S;
        ex2 = ex1;
        ex2(drop+1,:) = ex2(drop+1,:)+e1';   
        y1 = simult_(temps,dr,ex1,iorder);
        y2 = simult_(temps,dr,ex2,iorder);
        y = y+(y2(:,M_.maximum_lag+drop+1:end)-y1(:,M_.maximum_lag+drop+1:end));
        y_all(:,:,j)=y;
    end
    save IRFs y_all
    y=y/replic;

However, this is only a dirty hack without initialitizing y_all
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Gathering multiple IRFs

Postby nbt » Tue Oct 22, 2013 12:39 pm

Thank you Jpfeiffer. I think my problem is quite similar to this post (viewtopic.php?f=1&t=3215).
I know now that I have to add set_dynare_seed=(...) to the options of stoch_simul(...) instead of simul_seed (which seems to be outdated).
In the description of set_dynare_seed I see that there are two input argument a,b which correspond to the random number generator and its seed respectively.
According to the dynare manual one can also only put a single integer or double or expression in the argument set_dynare_seed(.).
But how exactly do I use this option. When I used 1 as an integer I got an error message on the mod file:
ERROR: BA_Perturbation_General.mod:40.45-59: syntax error, unexpected NAME

Thanks for your help,
nbt
nbt
 
Posts: 7
Joined: Sun Oct 13, 2013 12:12 pm

Re: Gathering multiple IRFs

Postby jpfeifer » Tue Oct 22, 2013 1:27 pm

Without the mod-file I cannot tell.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Gathering multiple IRFs

Postby nbt » Tue Oct 22, 2013 5:09 pm

ups sry
Attachments
BA_Perturbation_General.mod
(2.04 KiB) Downloaded 96 times
nbt
 
Posts: 7
Joined: Sun Oct 13, 2013 12:12 pm

Re: Gathering multiple IRFs

Postby jpfeifer » Mon Nov 04, 2013 9:23 am

set_dynare_seed is a standalone command. It is not an option of stoch_simul
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 6 guests