Page 1 of 1

How dynare simulates linearized DSGE models?(SOLVED)

PostPosted: Sun Sep 04, 2011 7:30 pm
by baltakar
''Thank you Stephane''


Hi,

I am currently working on a new moment based estimation method and I want to compare my results with those of Bayesian estimation.

The performances of estimation methods are analysed using the distance between simulated moments and the momets of the actual data.

Hence, to do this comparison, I need to generate simulated moments.

I am doing this in my matlab codes independent from Dynare perhaps using an old fashion standard way. I basically generate a random vector of shocks for each period then impose them continously to the state space solution.

The issue here is that there is a notable diffirence between my simulated moments and the simulated moments generated by the Dynare for the same posterior means (model is solved using Gensys for both cases).

I have been trying to track the dynare codes used for simulating the model and I cant go any further since:

case 1
[err, y_] = dynare_simul_(1,dr.nstatic,dr.npred-dr.nboth,dr.nboth,dr.nfwrd,M_.exo_nbr, ...
y_(dr.order_var,1),ex_',M_.Sigma_e,options_.DynareRandomStreams.seed,dr.ys(dr.order_var),...
zeros(M_.endo_nbr,1),dr.g_1);

dynare_simul_ is a a compiled C file and seeing inside is not an easy task.

Therefore I wanted to ask this forum first. Is there any information shows the actual implementation of stochastic simulations in Dynare. Any information including a paper, book, web-site etc can be very very useful.

Many thanks in advance,

Evren

Re: How dynare simulates linearized DSGE models?

PostPosted: Mon Sep 05, 2011 9:23 am
by StephaneAdjemian
Dear Evren,

You are using the dynare++ library. You will find documentation on this library on this page. Note that if you simulate the model with second order (or first order) perturbation you don't need to use this library... And you can then have a look at the matlab code.

Best,
Stéphane.

Re: How dynare simulates linearized DSGE models?

PostPosted: Mon Sep 05, 2011 11:01 pm
by baltakar
Thank you very much for the response Stephanie,

I reviewed the codes one more time. Am I missing something here? Can you let me summarize the steps towards simulationg the model:

1- In the main dynare file stoch_simul.m is called.

2- In this step the the order of the model is defined:

if options_.linear
options_.order = 1;
end

So this is my case since the model is linear.

3- line 123 of stoch_simul.m calls simult.m:

if options_.periods > 0 && ~PI_PCL_solver
if options_.periods <= options_.drop
disp(['STOCH_SIMUL error: The horizon of simulation is shorter' ...
' than the number of observations to be DROPed'])
options_ =options_old;
return
end
oo_.endo_simul = simult(oo_.dr.ys,oo_.dr);
dyn2vec;
end

4- line 65 of simult.m calles simult_.m:

for i=1:replic
if ~isempty(M_.Sigma_e)
oo_.exo_simul(:,i_exo_var) = randn(options_.periods,nxs)*chol_S
end
y_ = simult_(ys,dr,oo_.exo_simul,order)
% elimninating initial value
y_ = y_(:,2:end)
if replic > 1
fwrite(fh,y_,'float64')
end
end

5- then for the logical case=1 dynare_simul_.mex is called:

switch options_.order
case 1
[err, y_] = dynare_simul_(1,dr.nstatic,dr.npred-dr.nboth,dr.nboth,dr.nfwrd,M_.exo_nbr, ...
y_(dr.order_var,1),ex_',M_.Sigma_e,options_.DynareRandomStreams.seed,dr.ys(dr.order_var),...
zeros(M_.endo_nbr,1),dr.g_1);

Am I missing someting here?

Thanks,

Evren

Re: How dynare simulates linearized DSGE models?

PostPosted: Tue Sep 06, 2011 10:08 am
by StephaneAdjemian
Hi Evren, In step 5 Dynare goes to the mex routine because you probably used the option k_order_solver in stoch_simul (by default options_.k_order_solver is set to zero).
Best, Stéphane.