Page 1 of 1

Changing seed for impulse response calculations

PostPosted: Tue Jul 05, 2011 12:18 pm
by bruzzle
Hi,

I was wondering if there is a way to change the seed for random number generator to calculate impulse response functions. I want to simulate impulse response functions numerous times, but every time I do it I get exactly the same magnitudes and I thought it might be a problem about the seed of the random number generator. I have tried `set_dynare_seed' command to change the seed, but it did not work for impulse responses.

Thank you,

Re: Changing seed for impulse response calculations

PostPosted: Thu Jul 07, 2011 5:20 pm
by wjgatt
In the user guide pg 30 it says that unless you type simul_seed = INTEGER, a different sample is drawn with every run.

Re: Changing seed for impulse response calculations

PostPosted: Thu Jul 07, 2011 8:26 pm
by bruzzle
Hi wjgatt,

Thanks for the reply. I am using version 4 and it turns out that simul_seed is an obselete command for version 4. The relevant one is set_dynare_seed command, which only affects the data simulation but somehow not the impulse response calculations. I am not setting any seed at all in my .mod file and cannot find the seed in any of the .m files that calculates impulse responses. So always I get the same impulse responses, but I cannot find where the shocks are generated for the impulse responses to remove the seed if there is any. I would appreciate if you have an idea about where I can find the relevant shocks for impulse responses.

Thanks,

Re: Changing seed for impulse response calculations

PostPosted: Fri Jul 08, 2011 9:03 am
by jpfeifer
Hi, could you please post the mod-file.

Re: Changing seed for impulse response calculations

PostPosted: Sat Jul 09, 2011 8:01 am
by bruzzle
Hi jpfeifer,

I am working on Smets-Wouters(2007, AER). Here is the .mod file and the other needed files.

Thank you very much for the reply.

Re: Changing seed for impulse response calculations

PostPosted: Sat Jul 09, 2011 12:26 pm
by jpfeifer
You are using a linear model. Hence, there are no higher order terms. First order IRFs are not computed via simulations as they do not differ across the state space. While the seed works, it is not used in your application, because there is nothing to simulate.

Re: Changing seed for impulse response calculations

PostPosted: Sat Jul 09, 2011 1:52 pm
by bruzzle
Hi jpfeifer,

Thanks a lot for the reply.

I understand that impulse responses are solutions to the model and they are not simulated. So the functions themselves should be same. But the magnitudes of the deviations from the steady state are calculated according to a, say, one standard deviation shock. The shock itself should be random, thus it must be generated with some random number generator. Thus even though I have the same impulse response functions, I should have different magnitudes of deviations from the steady state for a given random shock with the specified standard deviation. This is why I thought there must be a seed for these shocks to make sure that deviations from the steady state are always the same for the sake of replicability.

Since there is nothing to simulate, set_dynare_seed is not working for this case, but I can't find where the shocks for IRFs are generated either.

Please let me know if there is knot in my thinking,

Thank you

Re: Changing seed for impulse response calculations

PostPosted: Mon Jul 11, 2011 5:32 pm
by jpfeifer
The Dynare manual clearly states what is done. In the linear case a Cholesky decomposition of the covariance-matrix if performed. This gives you a defined size of the shock (if the covariance matrix is diagonal, this corresponds to a shock of exactly one standard deviation). As the IRF-function is the same irregardless of the state-space region and the size of the shock is given by the decomposed covariance matrix, there is no random number to be used. In the linear case, there is simply no reason to draw random shocks from the shock distribution and average the IRF across many trials. You can directly work with the covariance matrix.

The respective code in stoch_simul is
Code: Select all
SS(M_.exo_names_orig_ord,M_.exo_names_orig_ord)=M_.Sigma_e+1e-14*eye(M_.exo_nbr)
cs = transpose(chol(SS))
y=irf(oo_.dr,cs(M_.exo_names_orig_ord,i), options_.irf, options_.drop, ...
                      options_.replic, options_.order);

where the second argument of irf is the shock vector with a one standard deviation size taken from the covariance matrix.