2023-09-08 14:22:52 +02:00
|
|
|
function disp_dr(M_,options_,dr,order,var_list)
|
|
|
|
%disp_dr(M_,options_,dr,order,var_list)
|
Fixes for ticket #57
preprocessor:
* add a field "M_.orig_endo_nbr" containing the nbr of endogenous before adding aux vars
* always provide "M_.aux_vars" (define it to "[]" when there is no aux var)
* rename "M_.aux_vars().orig_endo_index" to "M_.aux_vars().orig_index"
M-files:
* for commands which accept a list of variables (stoch_simul, osr, estimation, dynasave, dynatype, datatomfile), when no variable is given, use only the set of original endogenous (without aux vars) as the default
* when displaying the decision rule, when there is aux vars in the state variables, replace them by their original name (with the right lag)
* in "steady", don't display aux vars
* special exception for ramsey policy: all vars (including aux vars) are displayed, because the system of aux vars from ramsey policy is not compatible with the aux vars from the preprocessor
git-svn-id: https://www.dynare.org/svn/dynare/trunk@3166 ac1d8469-bf42-47a9-8791-bf33cf982152
2009-11-25 11:22:39 +01:00
|
|
|
% Display the decision rules
|
|
|
|
%
|
|
|
|
% INPUTS
|
2023-09-08 14:22:52 +02:00
|
|
|
% - M [structure] storing the model information
|
|
|
|
% - options [structure] storing the options
|
2019-02-25 17:14:57 +01:00
|
|
|
% - dr [struct] decision rules.
|
|
|
|
% - order [integer] order of approximation.
|
|
|
|
% - var_list [cell] list of endogenous variables for which the decision rules should be printed.
|
2017-05-16 15:10:20 +02:00
|
|
|
%
|
2019-02-25 17:14:57 +01:00
|
|
|
% OUTPUTS
|
|
|
|
% none
|
|
|
|
|
2023-01-13 16:19:53 +01:00
|
|
|
% Copyright © 2001-2023 Dynare Team
|
2008-08-01 20:53:30 +02:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
2021-06-09 17:33:48 +02:00
|
|
|
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2008-08-01 20:53:30 +02:00
|
|
|
|
2019-12-13 18:20:10 +01:00
|
|
|
if order~=1 && M_.hessian_eq_zero
|
2017-05-27 19:26:12 +02:00
|
|
|
order = 1;
|
|
|
|
warning('disp_dr: using order = 1 because Hessian is equal to zero');
|
|
|
|
end
|
2019-02-25 17:14:57 +01:00
|
|
|
|
2009-12-16 18:17:34 +01:00
|
|
|
nx =size(dr.ghx,2);
|
|
|
|
nu =size(dr.ghu,2);
|
2023-01-13 16:19:53 +01:00
|
|
|
k = find(dr.kstate(:,2) <= M_.maximum_lag+1);
|
|
|
|
klag = dr.kstate(k,[1 2]);
|
|
|
|
k1 = dr.order_var;
|
2009-12-16 18:17:34 +01:00
|
|
|
|
2017-10-10 10:05:59 +02:00
|
|
|
if isempty(var_list)
|
|
|
|
var_list = M_.endo_names(1:M_.orig_endo_nbr);
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
|
2017-10-10 10:05:59 +02:00
|
|
|
nvar = length(var_list);
|
2009-12-16 18:17:34 +01:00
|
|
|
|
|
|
|
ivar=zeros(nvar,1);
|
|
|
|
for i=1:nvar
|
2017-10-10 10:05:59 +02:00
|
|
|
i_tmp = strmatch(var_list{i}, M_.endo_names(k1), 'exact');
|
2009-12-16 18:17:34 +01:00
|
|
|
if isempty(i_tmp)
|
2017-10-10 10:05:59 +02:00
|
|
|
disp(var_list{i});
|
2019-02-25 17:14:57 +01:00
|
|
|
error ('One of the variable specified does not exist') ;
|
2009-12-16 18:17:34 +01:00
|
|
|
else
|
2010-01-05 11:46:10 +01:00
|
|
|
ivar(i) = i_tmp;
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
Fixes for ticket #57
preprocessor:
* add a field "M_.orig_endo_nbr" containing the nbr of endogenous before adding aux vars
* always provide "M_.aux_vars" (define it to "[]" when there is no aux var)
* rename "M_.aux_vars().orig_endo_index" to "M_.aux_vars().orig_index"
M-files:
* for commands which accept a list of variables (stoch_simul, osr, estimation, dynasave, dynatype, datatomfile), when no variable is given, use only the set of original endogenous (without aux vars) as the default
* when displaying the decision rule, when there is aux vars in the state variables, replace them by their original name (with the right lag)
* in "steady", don't display aux vars
* special exception for ramsey policy: all vars (including aux vars) are displayed, because the system of aux vars from ramsey policy is not compatible with the aux vars from the preprocessor
git-svn-id: https://www.dynare.org/svn/dynare/trunk@3166 ac1d8469-bf42-47a9-8791-bf33cf982152
2009-11-25 11:22:39 +01:00
|
|
|
|
2015-04-22 15:29:04 +02:00
|
|
|
% get length of display strings
|
|
|
|
header_label_length=16; %default
|
|
|
|
for ii=1:length(ivar)
|
2017-10-10 10:05:59 +02:00
|
|
|
header_label_length = max(header_label_length,length(M_.endo_names{k1(ivar(ii))})+2);
|
2015-04-22 15:29:04 +02:00
|
|
|
end
|
2020-12-23 10:36:59 +01:00
|
|
|
if options_.loglinear
|
|
|
|
header_label_length=header_label_length+5;
|
|
|
|
end
|
2015-04-22 15:29:04 +02:00
|
|
|
header_label_format = sprintf('%%%ds',header_label_length);
|
|
|
|
value_format_float = sprintf('%%%d.6f',header_label_length);
|
2022-02-20 11:00:34 +01:00
|
|
|
value_format_overflow = sprintf('%%%d.6e',header_label_length);
|
2015-04-22 15:29:04 +02:00
|
|
|
value_format_zero = sprintf('%%%dd',header_label_length);
|
|
|
|
|
|
|
|
% account for additional characters introduced by auxiliary variables
|
|
|
|
if ~isempty(M_.aux_vars)
|
|
|
|
aux_vars_type = [M_.aux_vars.type];
|
|
|
|
if any(aux_vars_type==4)
|
2022-12-19 16:03:51 +01:00
|
|
|
aux_var_additional_characters=17;
|
2015-04-22 15:29:04 +02:00
|
|
|
else
|
|
|
|
aux_var_additional_characters=3;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
aux_var_additional_characters=0;
|
|
|
|
end
|
|
|
|
|
2020-12-23 10:36:59 +01:00
|
|
|
if options_.loglinear
|
|
|
|
var_name_width = max([cellofchararraymaxlength(M_.endo_names(k1(ivar)))+5, cellofchararraymaxlength(M_.exo_names)]);
|
|
|
|
else
|
|
|
|
var_name_width = max([cellofchararraymaxlength(M_.endo_names(k1(ivar))), cellofchararraymaxlength(M_.exo_names)]);
|
|
|
|
end
|
2015-04-22 15:29:04 +02:00
|
|
|
%deal with covariances
|
|
|
|
if order > 1
|
2017-05-16 15:10:20 +02:00
|
|
|
var_name_width=max(2*(var_name_width+aux_var_additional_characters)+2,20); %account for covariances, separated by comma
|
2015-04-22 15:29:04 +02:00
|
|
|
else
|
|
|
|
var_name_width=max(var_name_width+aux_var_additional_characters,20);
|
|
|
|
end
|
|
|
|
label_format = sprintf('%%-%ds',var_name_width);
|
|
|
|
|
|
|
|
|
|
|
|
%% start displayimg
|
2009-12-16 18:17:34 +01:00
|
|
|
disp('POLICY AND TRANSITION FUNCTIONS')
|
|
|
|
% variable names
|
2017-05-16 15:10:20 +02:00
|
|
|
str = char(32*ones(1,var_name_width));
|
2009-12-16 18:17:34 +01:00
|
|
|
for i=1:nvar
|
2020-12-23 10:36:59 +01:00
|
|
|
if options_.loglinear
|
|
|
|
str = [str sprintf(header_label_format, ['log(',M_.endo_names{k1(ivar(i))},')'])];
|
|
|
|
else
|
|
|
|
str = [str sprintf(header_label_format, M_.endo_names{k1(ivar(i))})];
|
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
disp(str);
|
|
|
|
%
|
|
|
|
% constant
|
|
|
|
%
|
2015-04-22 15:29:04 +02:00
|
|
|
str=sprintf(label_format,'Constant');
|
2009-12-16 18:17:34 +01:00
|
|
|
flag = 0;
|
|
|
|
for i=1:nvar
|
2005-02-18 20:54:39 +01:00
|
|
|
x = dr.ys(k1(ivar(i)));
|
|
|
|
if order > 1
|
2009-12-16 18:17:34 +01:00
|
|
|
x = x + dr.ghs2(ivar(i))/2;
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
2022-02-20 11:00:34 +01:00
|
|
|
[str,flag]=get_print_string(str,x,value_format_zero,value_format_float,value_format_overflow,header_label_length,flag,options_);
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
if flag
|
2005-02-18 20:54:39 +01:00
|
|
|
disp(str)
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
if order > 1
|
2015-04-22 15:29:04 +02:00
|
|
|
str = sprintf(label_format,'(correction)');
|
2005-02-18 20:54:39 +01:00
|
|
|
flag = 0;
|
|
|
|
for i=1:nvar
|
2009-12-16 18:17:34 +01:00
|
|
|
x = dr.ghs2(ivar(i))/2;
|
2022-02-20 11:00:34 +01:00
|
|
|
[str,flag]=get_print_string(str,x,value_format_zero,value_format_float,value_format_overflow,header_label_length,flag,options_);
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
|
|
|
if flag
|
2009-12-16 18:17:34 +01:00
|
|
|
disp(str)
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
%
|
|
|
|
% ghx
|
|
|
|
%
|
|
|
|
for k=1:nx
|
2005-02-18 20:54:39 +01:00
|
|
|
flag = 0;
|
2012-07-13 10:30:09 +02:00
|
|
|
if isfield(dr,'state_var')
|
2021-09-09 14:46:02 +02:00
|
|
|
str1 = subst_auxvar(dr.state_var(k),-1,M_);
|
2012-07-13 10:30:09 +02:00
|
|
|
else
|
2021-09-09 14:46:02 +02:00
|
|
|
str1 = subst_auxvar(k1(klag(k,1)),klag(k,2)-M_.maximum_lag-2,M_);
|
2012-07-13 10:30:09 +02:00
|
|
|
end
|
2020-12-23 10:36:59 +01:00
|
|
|
if options_.loglinear
|
|
|
|
str = sprintf(label_format,['log(',str1,')']);
|
|
|
|
else
|
|
|
|
str = sprintf(label_format,str1);
|
|
|
|
end
|
2005-02-18 20:54:39 +01:00
|
|
|
for i=1:nvar
|
2011-10-12 14:48:28 +02:00
|
|
|
x = dr.ghx(ivar(i),k);
|
2022-02-20 11:00:34 +01:00
|
|
|
[str,flag]=get_print_string(str,x,value_format_zero,value_format_float,value_format_overflow,header_label_length,flag,options_);
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
|
|
|
if flag
|
2009-12-16 18:17:34 +01:00
|
|
|
disp(str)
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
%
|
|
|
|
% ghu
|
|
|
|
%
|
|
|
|
for k=1:nu
|
2005-02-18 20:54:39 +01:00
|
|
|
flag = 0;
|
2017-10-10 10:05:59 +02:00
|
|
|
str = sprintf(label_format, M_.exo_names{k});
|
2005-02-18 20:54:39 +01:00
|
|
|
for i=1:nvar
|
2011-10-12 14:48:28 +02:00
|
|
|
x = dr.ghu(ivar(i),k);
|
2022-02-20 11:00:34 +01:00
|
|
|
[str,flag] = get_print_string(str, x, value_format_zero, value_format_float, value_format_overflow, header_label_length, flag, options_);
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
|
|
|
if flag
|
2009-12-16 18:17:34 +01:00
|
|
|
disp(str)
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
2005-02-18 20:54:39 +01:00
|
|
|
|
2009-12-16 18:17:34 +01:00
|
|
|
if order > 1
|
2005-02-18 20:54:39 +01:00
|
|
|
% ghxx
|
|
|
|
for k = 1:nx
|
2009-12-16 18:17:34 +01:00
|
|
|
for j = 1:k
|
|
|
|
flag = 0;
|
2021-09-09 14:46:02 +02:00
|
|
|
str1 = sprintf('%s,%s',subst_auxvar(k1(klag(k,1)),klag(k,2)-M_.maximum_lag-2,M_), ...
|
|
|
|
subst_auxvar(k1(klag(j,1)),klag(j,2)-M_.maximum_lag-2,M_));
|
2017-10-10 10:05:59 +02:00
|
|
|
str = sprintf(label_format, str1);
|
2009-12-16 18:17:34 +01:00
|
|
|
for i=1:nvar
|
|
|
|
if k == j
|
|
|
|
x = dr.ghxx(ivar(i),(k-1)*nx+j)/2;
|
|
|
|
else
|
|
|
|
x = dr.ghxx(ivar(i),(k-1)*nx+j);
|
|
|
|
end
|
2022-02-20 11:00:34 +01:00
|
|
|
[str,flag]=get_print_string(str,x,value_format_zero,value_format_float,value_format_overflow,header_label_length,flag,options_);
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
if flag
|
|
|
|
disp(str)
|
|
|
|
end
|
|
|
|
end
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
|
|
|
%
|
|
|
|
% ghuu
|
|
|
|
%
|
|
|
|
for k = 1:nu
|
2009-12-16 18:17:34 +01:00
|
|
|
for j = 1:k
|
|
|
|
flag = 0;
|
2017-10-10 10:05:59 +02:00
|
|
|
str = sprintf(label_format, [M_.exo_names{k} ',' M_.exo_names{j}]);
|
2009-12-16 18:17:34 +01:00
|
|
|
for i=1:nvar
|
|
|
|
if k == j
|
|
|
|
x = dr.ghuu(ivar(i),(k-1)*nu+j)/2;
|
|
|
|
else
|
|
|
|
x = dr.ghuu(ivar(i),(k-1)*nu+j);
|
|
|
|
end
|
2022-02-20 11:00:34 +01:00
|
|
|
[str,flag]=get_print_string(str, x, value_format_zero, value_format_float, value_format_overflow, header_label_length, flag, options_);
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
if flag
|
|
|
|
disp(str)
|
|
|
|
end
|
|
|
|
end
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
|
|
|
%
|
|
|
|
% ghxu
|
|
|
|
%
|
|
|
|
for k = 1:nx
|
2009-12-16 18:17:34 +01:00
|
|
|
for j = 1:nu
|
|
|
|
flag = 0;
|
2021-09-09 14:46:02 +02:00
|
|
|
str1 = sprintf('%s,%s',subst_auxvar(k1(klag(k,1)),klag(k,2)-M_.maximum_lag-2,M_), M_.exo_names{j});
|
2015-04-22 15:29:04 +02:00
|
|
|
str = sprintf(label_format,str1);
|
2009-12-16 18:17:34 +01:00
|
|
|
for i=1:nvar
|
|
|
|
x = dr.ghxu(ivar(i),(k-1)*nu+j);
|
2022-02-20 11:00:34 +01:00
|
|
|
[str,flag]=get_print_string(str,x,value_format_zero,value_format_float,value_format_overflow,header_label_length,flag,options_);
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
if flag
|
|
|
|
disp(str)
|
|
|
|
end
|
|
|
|
end
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
Fixes for ticket #57
preprocessor:
* add a field "M_.orig_endo_nbr" containing the nbr of endogenous before adding aux vars
* always provide "M_.aux_vars" (define it to "[]" when there is no aux var)
* rename "M_.aux_vars().orig_endo_index" to "M_.aux_vars().orig_index"
M-files:
* for commands which accept a list of variables (stoch_simul, osr, estimation, dynasave, dynatype, datatomfile), when no variable is given, use only the set of original endogenous (without aux vars) as the default
* when displaying the decision rule, when there is aux vars in the state variables, replace them by their original name (with the right lag)
* in "steady", don't display aux vars
* special exception for ramsey policy: all vars (including aux vars) are displayed, because the system of aux vars from ramsey policy is not compatible with the aux vars from the preprocessor
git-svn-id: https://www.dynare.org/svn/dynare/trunk@3166 ac1d8469-bf42-47a9-8791-bf33cf982152
2009-11-25 11:22:39 +01:00
|
|
|
end
|
2005-02-18 20:54:39 +01:00
|
|
|
|
2015-04-22 15:29:04 +02:00
|
|
|
|
2022-02-20 11:00:34 +01:00
|
|
|
function [str,flag]=get_print_string(str, x, value_format_zero, value_format_float, value_format_overflow, max_length, flag, options_)
|
2017-05-16 15:10:20 +02:00
|
|
|
if abs(x) >= options_.dr_display_tol
|
|
|
|
flag = 1;
|
2022-02-20 11:00:34 +01:00
|
|
|
temp=sprintf(value_format_float, x);
|
|
|
|
if length(temp)>max_length
|
|
|
|
temp=sprintf(value_format_overflow, x);
|
|
|
|
end
|
|
|
|
str = [str temp];
|
2017-05-16 15:10:20 +02:00
|
|
|
else
|
2017-10-10 10:05:59 +02:00
|
|
|
str = [str sprintf(value_format_zero, 0)];
|
2017-05-16 15:10:20 +02:00
|
|
|
end
|
2019-12-13 18:20:10 +01:00
|
|
|
end
|