Page 1 of 1

IRF second order with large shock, Dynare 4.2.1

PostPosted: Tue Apr 03, 2012 9:27 am
by 616Dynare
Hi,

I tried to replicate the IRF of Dynare 4.2.1 for 2nd-order approximation, using Dynare's policy functions. It seems to be fine for small shocks, but for large shocks there is a difference between Dynare-based irfs and irfs computed using Dynare's policy functions (I eliminate the issues regarding the seed, drop periods, etc. by fixing the seed for random numbers and looking at only one shock). I attach the Dynare file and a file that computes the IRFs and plots the differences. There are even small differences for the shock process (z), which seems particularly strange. Am I just being silly and overlooking something?

Thanx a lot!

P.S.: In fact, e1 in Dynare's irf is 0.070000000000071. Shouldn't it be just 0.07 if the shock is 0.07?
P.P.S.: To follow up: Controlling for the seed within the .mod file does not seem to work. If I control for the random number seed in Dynare's irf.m file (just before ex1(:,i_exo_var) = randn(long+drop,nxs)*chol_S;), then this guarantees that Dynare's and my IRFs are based on exactly the same random numbers. However, the issue with e1 remains - the shock size in Dynare is slightly different (e1=0.070000000000071 instead of 0.07). I guess this is a numerical issue, but it might nevertheless be annoying if one wants to compare accuracy...

Re: IRF second order with large shock, Dynare 4.2.1

PostPosted: Wed Apr 18, 2012 7:01 pm
by jpfeifer
Your problem is line 154 of stoch_simul. To avoid problems with semidefinite covariance matrices, Dynare adds 1e-14 to the covariance matrix:
Code: Select all
    SS(M_.exo_names_orig_ord,M_.exo_names_orig_ord)=M_.Sigma_e+1e-14*eye(M_.exo_nbr);

before doing a Cholesky decomposition. If you comment out the plus part, everything should be fine.

Re: IRF second order with large shock, Dynare 4.2.1

PostPosted: Wed Apr 25, 2012 2:54 pm
by 616Dynare
Excellent! Thank you very much!