How dynare simulates linearized DSGE models?(SOLVED)

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.

How dynare simulates linearized DSGE models?(SOLVED)

Postby baltakar » Sun Sep 04, 2011 7:30 pm

''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
Last edited by baltakar on Tue Sep 06, 2011 10:26 pm, edited 1 time in total.
baltakar
 
Posts: 2
Joined: Wed Jan 19, 2011 10:28 am

Re: How dynare simulates linearized DSGE models?

Postby StephaneAdjemian » Mon Sep 05, 2011 9:23 am

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.
Stéphane Adjemian
Université du Maine, GAINS and DynareTeam
https://stepan.adjemian.eu
StephaneAdjemian
 
Posts: 429
Joined: Wed Jan 05, 2005 4:24 pm
Location: Paris, France.

Re: How dynare simulates linearized DSGE models?

Postby baltakar » Mon Sep 05, 2011 11:01 pm

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
baltakar
 
Posts: 2
Joined: Wed Jan 19, 2011 10:28 am

Re: How dynare simulates linearized DSGE models?

Postby StephaneAdjemian » Tue Sep 06, 2011 10:08 am

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.
Stéphane Adjemian
Université du Maine, GAINS and DynareTeam
https://stepan.adjemian.eu
StephaneAdjemian
 
Posts: 429
Joined: Wed Jan 05, 2005 4:24 pm
Location: Paris, France.


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 13 guests