Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
dynare
dynare
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 121
    • Issues 121
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 1
    • Merge Requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Dynare
  • dynaredynare
  • Wiki
  • BreakingFeaturesIn4.6

Last edited by Houtan Bastani Mar 06, 2020
Page history

BreakingFeaturesIn4.6

Breaking features in version 4.6

Version 4.6 brings many improvements but also some breaking changes. The most important of them concerns Dynare internals that will affect users who expand Dynare with their own Matlab code.

We most strongly encourage you modify your own code to comply with the new version. Relying on an older version of Dynare to run your own code may seem as a gain of time in the short term but will lead to more problems later. Note also that possible bugs found later in version 4.5.7 won't be fixed in that version. We expect users to run version 4.6 from now on.

Changes related to the Dynare command line

To better handle macro expressions passed on the command line, double quotes are no longer dropped when present in command line options. In earlier versions of Dynare, they were ignored when they surrounded an argument. Hence,

dynare example1.mod conffile="C:\User\Docs\config.txt"

can now simply become

dynare example1.mod conffile=C:\User\Docs\config.txt

as the quotes are not part of the filename we want to open. In a corresponding change, if the argument you are passing on the command line contains whitespace, the entire option (option name and value) must be single quoted. e.g.

dynare <<modfile.mod>> -DA=true '-DB="A string with space"' -DC=[1,2,3] '-DCbis=[1, 2,3]' '-DD=[ i in C when i > 1 ]' 'conffile=C:\User\My Docs\config.txt'

Changes related to Dynare commands

  1. In order to allow for interpretable expressions within moment_calibration and irf_calibration-blocks, upper and lower bounds now need to be separated by a comma. For example, a range between zero and one
irf_calibration;
y(1:4), e_ys, [0 1];
end;

now needs to be specified as

irf_calibration;
y(1:4), e_ys, [0, 1];
end;
  1. The results of the conditional_forecast command are now saved in the output structure oo_ under oo_.conditional_forecast. They are not saved to hard-disk in a file called conditional_forecasts.mat anymore. Code needs to be adjusted to reference the structure subfield instead of loading it from the disk.
  2. The Dynare macro-processor now allows for nested arrays, i.e. defining arrays that contain other arrays. As a consequence, the old ambiguous syntax needed to be replaced by something unambiguous. In Dynare 4.5, [1:2] was equivalent to 1:2. Both definitions created an array of integers. In Dynare 4.6 this has changed. 1:2 still creates an array of integers, while [1:2] will create an array within an array. This implies that in most cases the squared brackets around ranges need to be removed if algebra is performed on the array members. For example, in Dynare 4.5 you could sum integers by writing
@#define a = 3
@#for i in [1:4]
  @#define b = i+a
@#endfor

This will not work in Dynare 4.6, because now your are adding an integer a to a an array of integers in i. The error message will typically be something along the lines of

Macro-processing error: backtrace...
- Type mismatch for operands of + operator
- binary operation: "model_name.mod" line x, col x-xx

The correct code in Dynare 4.6 would be

@#define a = 3
@#for i in 1:4
  @#define b = i+a
@#endfor

Note the deleted brackets in the definition of the range 1:4.

  1. The Dynare macro-processor now performs division with doubles instead of integers. For example, 3/2 used to result in 1, now it results in 1.5. To restore the old behavior, one needs to replace
a/b

by

floor(a/b)
  1. The ramsey_policy-command is now deprecated. It is superseded by calls to ramsey_policy, stoch_simul, and evaluate_planner_objective. This allows for better control of the individual elements going into the computations. For example, to achieve the same results as previously with
ramsey_policy(planner_discount=0.99,order=1,instruments=(r),periods=500,irf=25);

the new syntax is

ramsey_model(planner_discount=0.99,instruments=(r));
stoch_simul(order=1,periods=500,irf=25);
evaluate_planner_objective;

The ramsey_model-command sets up the Ramsey problem, while stoch_simul solves the model with perturbation techniques, conducts stochastic simulations, and computes IRFs. Finally, evaluate_planner_objective computes and displays the value of the planner_objective.

Changes related to Dynare internals

  1. Dynare has phased out the use of global variables in stoch_simul and its related subfunctions like simult_, irf, and discretionary_policy (see e043c609). In case you looped over stoch_simul using a call to
info = stoch_simul(var_list_);

you now need to now add the previous three global variables M_, options_, oo_ as the first inputs:

[info, oo_, options_] = stoch_simul(M_, options_, oo_, var_list_);

Previous calls to simult_ like

y_sim_one_shock = simult_(y0,oo_.dr,temp_shock_mat,options_.order);

need to add the previous two global variables M_,options_ as their first two inputs:

y_sim_one_shock = simult_(M_,options_,y0,oo_.dr,temp_shock_mat,options_.order);
  1. List of names have been converted from character arrays to cell arrays of strings. This affects M_.endo_names, M_.exo_names, M_.param_names, oo_.var_list, and options_.varobs. For that reason, you may have to replace round by curly brackets.
  2. In addition, Dynare 4.6 has phased out the use of global variables in user-defined steady state files (see 0c01c314). Instead, the model structure M_ and the options-structure options_ are now passed as input arguments, while the parameter vector params has become an output argument.
  3. Related to the previous three changes, user-defined steady state files need to be adjusted for i) the interface change related to globals and ii) for the reading out of variables and parameters to be compatible with the cell arrays. In case you are using legacy files, you will generally encounter the error message

Error using Modelname_steadystate Too many input arguments.

Error in evaluate_steady_state_file (line 49) [ys,params1,check] = h_steadystate(ys_init, exo_ss,M,options); and

or

Error using eval Must be a string scalar or character vector.

Error in Model_name_steadystate (line 21) eval([ paramname ' = M_.params(' int2str(ii) ');']);

In Dynare 4.5.7, the interface for _steady_state.m-files used to be

function [ys,check] = NK_baseline_steadystate(ys,exo)
% function [ys,check] = NK_baseline_steadystate(ys,exo)
% computes the steady state for the NK_baseline.mod and uses a numerical
% solver to do so
% Inputs: 
%   - ys        [vector] vector of initial values for the steady state of
%                   the endogenous variables
%   - exo       [vector] vector of values for the exogenous variables
%
% Output: 
%   - ys        [vector] vector of steady state values fpr the the endogenous variables
%   - check     [scalar] set to 0 if steady state computation worked and to
%                    1 of not (allows to impos restriction on parameters)

global M_ 

% read out parameters to access them with their name
NumberOfParameters = M_.param_nbr;
for ii = 1:NumberOfParameters
  paramname = deblank(M_.param_names(ii,:));
  eval([ paramname ' = M_.params(' int2str(ii) ');']);
end
% initialize indicator
check = 0;

In Dynare 4.6 instead the required interface is

function [ys,params,check] = NK_baseline_steadystate(ys,exo,M_,options_)
% function [ys,params,check] = NK_baseline_steadystate(ys,exo,M_,options_)
% computes the steady state for the NK_baseline.mod and uses a numerical
% solver to do so
% Inputs: 
%   - ys        [vector] vector of initial values for the steady state of
%                   the endogenous variables
%   - exo       [vector] vector of values for the exogenous variables
%   - M_        [structure] Dynare model structure
%   - options   [structure] Dynare options structure
%
% Output: 
%   - ys        [vector] vector of steady state values for the the endogenous variables
%   - params    [vector] vector of parameter values
%   - check     [scalar] set to 0 if steady state computation worked and to
%                    1 of not (allows to impose restrictions on parameters)

% read out parameters to access them with their name
NumberOfParameters = M_.param_nbr;
for ii = 1:NumberOfParameters
  paramname = M_.param_names{ii};
  eval([ paramname ' = M_.params(' int2str(ii) ');']);
end
% initialize indicator
check = 0;

Note the interface change in the first line and the use of curly brackets within the loop.

For writing back the steady state to ys and the parameters to params, the code at the bottom of the steady state file used to be

for iter = 1:length(M_.params) %update parameters set in the file
  eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';' ])
end

NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
  varname = deblank(M_.endo_names(ii,:));
  eval(['ys(' int2str(ii) ') = ' varname ';']);
end

It now needs to be replaced by

params=NaN(NumberOfParameters,1);
for iter = 1:length(M_.params) %update parameters set in the file
  eval([ 'params(' num2str(iter) ') = ' M_.param_names{iter} ';' ])
end

NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
  varname = M_.endo_names{ii};
  eval(['ys(' int2str(ii) ') = ' varname ';']);
end

Note that you now need to span the full parameter vector params first and that again curly brackets are used within the loops.

  1. The names of most functions related to identification have changed to become more expressive. See 666c9b80
Clone repository
  • Auxiliary variables
  • BreakingFeaturesIn4.6
  • DSGE VAR model
  • External function
  • FixedBugs
  • Home
  • Install on MacOS
  • Known bugs present in the current stable version
  • MATLAB Versions
  • NewFeatures
  • Particle filters
  • RoadMap
  • mode compute 6