Temporary fix for growth parameter in PAC models

The preprocessor has been modified to allow linear combinations in the growth
parameter (see Dynare/preprocessor@a0f74f5c16 and
Dynare/preprocessor@d873414728).

This commit restores the previous functionality (i.e. it fixes the simple case
where only one parameter/variable is provided for the growth parameter).

The code still needs to be adapted to really handle linear combinations.
time-shift
Sébastien Villemot 2019-09-24 18:09:42 +02:00
parent e2c57dc5f5
commit 8e1528c1cb
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 19 additions and 9 deletions

View File

@ -418,19 +418,24 @@ function [PacExpectations, Model] = UpdatePacExpectationsData(dataPAC0, dataPAC1
% Add correction for growth neutrality if required.
correction = 0;
if isfield(Model.pac.(pacmodl), 'growth_type')
switch Model.pac.(pacmodl).growth_type
if numel(Model.pac.(pacmodl).growth_type) > 1 || ...
Model.pac.(pacmodl).growth_constant(1) ~= 1 || ...
Model.pac.(pacmodl).growth_param_id(1) ~= 0
error('Linear combinations in growth parameter are not yet supported')
end
switch Model.pac.(pacmodl).growth_type{1}
case 'parameter'
correction = Model.params(Model.pac.(pacmodl).growth_index)*Model.params(Model.pac.(pacmodl).growth_neutrality_param_index);
correction = Model.params(Model.pac.(pacmodl).growth_index(1))*Model.params(Model.pac.(pacmodl).growth_neutrality_param_index);
case 'exogenous'
GrowthVariable = data{Model.exo_names{Model.pac.(pacmodl).growth_index}};
GrowthVariable = data{Model.exo_names{Model.pac.(pacmodl).growth_index(1)}};
GrowthVariable = GrowthVariable(range).data;
correction = GrowthVariable*Model.params(Model.pac.(pacmodl).growth_neutrality_param_index);
case 'endogenous'
GrowthVariable = data{Model.endo_names{Model.pac.(pacmodl).growth_index}}.lag(abs(Model.pac.(pacmodl).growth_lag));
GrowthVariable = data{Model.endo_names{Model.pac.(pacmodl).growth_index(1)}}.lag(abs(Model.pac.(pacmodl).growth_lag(1)));
GrowthVariable = GrowthVariable(range).data;
correction = GrowthVariable*Model.params(Model.pac.(pacmodl).growth_neutrality_param_index);
otherwise
error('Not yet implemented.')
end
end
PacExpectations = PacExpectations+correction;
PacExpectations = PacExpectations+correction;

View File

@ -307,23 +307,28 @@ for i=1:maxlag
end
if isequal(id, 1)
if isequal(expectationmodelkind, 'pac') && growth_correction
if numel(expectationmodel.growth_type) > 1 || ...
expectationmodel.growth_constant(1) ~= 1 || ...
expectationmodel.growth_param_id(1) ~= 0
error('Linear combinations in growth parameter are not yet supported')
end
pgrowth = M_.params(expectationmodel.growth_neutrality_param_index);
vgrowth = expectationmodel.growth_str;
switch expectationmodel.growth_type
switch expectationmodel.growth_type{1}
case 'parameter'
vgrowth = M_.params(strcmp(vgrowth, M_.param_names));
otherwise
vgrowth = regexprep(vgrowth, '\<(?!diff\>)\<(?!log\>)\<(?!\d\>)\w+', 'dbase.$0');
end
if parameter>=0
switch expectationmodel.growth_type
switch expectationmodel.growth_type{1}
case 'parameter'
expression = sprintf('%s*%s+%s*%s', num2str(pgrowth, '%1.16f'), num2str(vgrowth, '%1.16f'), num2str(parameter, '%1.16f'), variable);
otherwise
expression = sprintf('%s*%s+%s*%s', num2str(pgrowth, '%1.16f'), vgrowth, num2str(parameter, '%1.16f'), variable);
end
else
switch expectationmodel.growth_type
switch expectationmodel.growth_type{1}
case 'parameter'
expression = sprintf('%s*%s-%s*%s', num2str(pgrowth, '%1.16f'), num2str(vgrowth, '%1.16f'), num2str(-parameter, '%1.16f'), variable);
otherwise
@ -348,4 +353,4 @@ fclose(fid);
fprintf('Expectation dseries expression is saved in %s.\n', filename);
skipline();
skipline();