Deterministic simulation sim1.m

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.

Deterministic simulation sim1.m

Postby Peter Zar » Tue Feb 04, 2014 12:06 pm

Dear all,

I am trying to understand the simul command in dynare. In sim1.m there is the following code which I do not understand at all:

model_dynamic = str2func([M_.fname,'_dynamic']);
z = Y(find(lead_lag_incidence'));
[d1,jacobian] = model_dynamic(z,oo_.exo_simul, params, ...
steady_state,2);

The Y is the stacked vector of all variables (to be determined) at all times of the simulation. At that point it is Y=[Y0,Y1,Y1,...Y1]', thus the initial points and then the end points times the time of simulation.
The lead_lag_incidence determines the characteristc of each variable (backward looking, forward looking or present).
So far correct?
I do not understand what model_dynamic is (except that it is a function...but what does it do?).
I also do not understand the z variable since it stores values of initial steady states and future steady states.
Last but not least, I do not get the model_dynamic() and what it does. I tried
[d1,jacobian111] = model_dynamic(z,oo_.exo_simul, params, ...
steady_state,2)
AAA=model_dynamic(z,oo_.exo_simul, params, ...
steady_state,2)
[d2,jacobian1] = AAA

The first command works, for the second and third together I get "Too many output arguments."

Any help is very much appreciated!

Best
Peter Zar
 
Posts: 14
Joined: Tue Jan 21, 2014 12:02 pm

Re: Deterministic simulation sim1.m

Postby jpfeifer » Wed Feb 05, 2014 9:50 am

model_dynamic is a link to the _dynamic-function created by Dynare. You can find that function in the folder where your mod-file is located after running Dynare. If your model is cally mymodel.mod the file will be mymodel_dynamic.m. This file computes the things as indicated in the header of that file:

function [residual, g1, g2, g3] = mymodel_dynamic(y, x, params, steady_state, it_)
%
% Status : Computes dynamic model for Dynare
%
% Inputs :
% y [#dynamic variables by 1] double vector of endogenous variables in the order stored
% in M_.lead_lag_incidence; see the Manual
% x [M_.exo_nbr by nperiods] double matrix of exogenous variables (in declaration order)
% for all simulation periods
% params [M_.param_nbr by 1] double vector of parameter values in declaration order
% it_ scalar double time period for exogenous variables for which to evaluate the model
%
% Outputs:
% residual [M_.endo_nbr by 1] double vector of residuals of the dynamic model equations in order of
% declaration of the equations
% g1 [M_.endo_nbr by #dynamic variables] double Jacobian matrix of the dynamic model equations;
% columns: equations in order of declaration
% rows: variables in order stored in M_.lead_lag_incidence
% g2 [M_.endo_nbr by (#dynamic variables)^2] double Hessian matrix of the dynamic model equations;
% columns: equations in order of declaration
% rows: variables in order stored in M_.lead_lag_incidence
% g3 [M_.endo_nbr by (#dynamic variables)^3] double Third order derivative matrix of the dynamic model equations;
% columns: equations in order of declaration
% rows: variables in order stored in M_.lead_lag_incidence
%
%
% Warning : this file is generated automatically by Dynare
% from model file (.mod)

%
% Model equations
%


That is, given the value for the variables in z, it computes the residuals as well as the derivatives of the model.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Deterministic simulation sim1.m

Postby Peter Zar » Mon Feb 24, 2014 3:49 pm

Thank you for your answer!
One more question: Is there a documentation of how perfect foresight is implemented in Dynare? I am only aware of Juillard 1996, but I read from Sebastian Villemots slides of the summer school in 2012 that it is computed differently nowadays. However, I haven't found any references.

Appreciate any comments, best
Peter
Attachments
Juillard1996.pdf
(183.32 KiB) Downloaded 136 times
Villemot2012.pdf
(267.25 KiB) Downloaded 182 times
Peter Zar
 
Posts: 14
Joined: Tue Jan 21, 2014 12:02 pm

Re: Deterministic simulation sim1.m

Postby SébastienVillemot » Thu Feb 27, 2014 3:26 pm

I attach slides that give a little more details about the methods used in Dynare for perfect foresight.

The default method (option "stack_solve_algo=0") is now a simple Newton algorithm run on the stacked system for all the periods, using sparse matrix algebra. The problem is described in the slides 15 and 21.

Formerly, the default method was relaxation (also known as Laffargue-Boucekkine-Juillard), and it is still available with option "stack_solve_algo=6". It is described in slides 16 to 20.

There are alternative methods based on block decomposition for better performance on big models, implemented by Ferhat Mihoubi. They are only hinted at in slides 22 to 24. I attach Ferhat's slides that give more details.
Attachments
ferhat-slides.pdf
(534.1 KiB) Downloaded 224 times
deterministic.pdf
(323.3 KiB) Downloaded 251 times
Sébastien Villemot
Economist at OFCE – Sciences Po
SébastienVillemot
 
Posts: 706
Joined: Fri Dec 07, 2007 2:29 pm
Location: Paris, France


Return to Dynare contributions and examples

Who is online

Users browsing this forum: No registered users and 5 guests