Page 1 of 1

Gathering multiple IRFs

PostPosted: Mon Oct 14, 2013 5:44 pm
by nbt
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

Re: Gathering multiple IRFs

PostPosted: Mon Oct 14, 2013 7:54 pm
by jpfeifer
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.

Re: Gathering multiple IRFs

PostPosted: Tue Oct 15, 2013 2:13 pm
by nbt
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!

Re: Gathering multiple IRFs

PostPosted: Tue Oct 22, 2013 10:09 am
by jpfeifer
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

Re: Gathering multiple IRFs

PostPosted: Tue Oct 22, 2013 12:39 pm
by nbt
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

Re: Gathering multiple IRFs

PostPosted: Tue Oct 22, 2013 1:27 pm
by jpfeifer
Without the mod-file I cannot tell.

Re: Gathering multiple IRFs

PostPosted: Tue Oct 22, 2013 5:09 pm
by nbt
ups sry

Re: Gathering multiple IRFs

PostPosted: Mon Nov 04, 2013 9:23 am
by jpfeifer
set_dynare_seed is a standalone command. It is not an option of stoch_simul