Bug fixes.
- cherrypick routine was not returning the correct lists of endogenous and exogenous variables. The number of endogenous variables was even not matching the number of equations. - In some cases LHS expressions were not preprocessed to extract the name of an endogenous variable. - Return a non cryptic error message if more than one endogenous variable appears in the LHS.time-shift
parent
7e849f01ad
commit
3fcca321a2
|
@ -81,7 +81,13 @@ for i=1:length(eqtags)
|
||||||
% Get the original equation.
|
% Get the original equation.
|
||||||
[LHS, RHS] = get_lhs_and_rhs(eqtags{i}, M_, true);
|
[LHS, RHS] = get_lhs_and_rhs(eqtags{i}, M_, true);
|
||||||
% Get the parameters, endogenous and exogenous variables in the current equation.
|
% Get the parameters, endogenous and exogenous variables in the current equation.
|
||||||
[pnames, enames, xnames] = get_variables_and_parameters_in_equation(LHS, RHS, M_);
|
[pnames, ~, xnames] = get_variables_and_parameters_in_equation(LHS, RHS, M_);
|
||||||
|
LHS = get_variables_and_parameters_in_expression(LHS);
|
||||||
|
enames = LHS;
|
||||||
|
if length(LHS)>1
|
||||||
|
error('Expressions with more than one variable on the LHS are not allowed.')
|
||||||
|
end
|
||||||
|
LHS = LHS{1};
|
||||||
if isrename
|
if isrename
|
||||||
[variable_has_to_be_renamed, id] = ismember(eqnum, [rename{:,1}]);
|
[variable_has_to_be_renamed, id] = ismember(eqnum, [rename{:,1}]);
|
||||||
if variable_has_to_be_renamed
|
if variable_has_to_be_renamed
|
||||||
|
@ -123,14 +129,13 @@ for i=1:length(eqtags)
|
||||||
rhs = write_expectations(eqtags{i}, isvar.name, 'var');
|
rhs = write_expectations(eqtags{i}, isvar.name, 'var');
|
||||||
lhs = sprintf('%s_VE', eqtags{i});
|
lhs = sprintf('%s_VE', eqtags{i});
|
||||||
RHS = strrep(RHS, sprintf('var_expectation(model_name = %s)', isvar.name), lhs);
|
RHS = strrep(RHS, sprintf('var_expectation(model_name = %s)', isvar.name), lhs);
|
||||||
else
|
end
|
||||||
if ~isempty(ispac)
|
if ~isempty(ispac)
|
||||||
[rhs, growthneutralitycorrection] = write_expectations(eqtags{i}, ispac.name, 'pac');
|
[rhs, growthneutralitycorrection] = write_expectations(eqtags{i}, ispac.name, 'pac');
|
||||||
lhs = sprintf('%s_PE', eqtags{i});
|
lhs = sprintf('%s_PE', eqtags{i});
|
||||||
RHS = strrep(RHS, sprintf('pac_expectation(model_name = %s)', ispac.name), lhs);
|
RHS = strrep(RHS, sprintf('pac_expectation(model_name = %s)', ispac.name), lhs);
|
||||||
if ~isempty(growthneutralitycorrection)
|
if ~isempty(growthneutralitycorrection)
|
||||||
RHS = sprintf('%s + %s', RHS, growthneutralitycorrection);
|
RHS = sprintf('%s + %s', RHS, growthneutralitycorrection);
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
% Print equation for unrolled PAC/VAR-expectation and update
|
% Print equation for unrolled PAC/VAR-expectation and update
|
||||||
|
@ -139,12 +144,20 @@ for i=1:length(eqtags)
|
||||||
% Note that the call to get_variables_and_parameters_in_equation()
|
% Note that the call to get_variables_and_parameters_in_equation()
|
||||||
% will not return the lhs variable in expectation_enames since
|
% will not return the lhs variable in expectation_enames since
|
||||||
% the name is created on the fly and is not a member of M_.endo_names.
|
% the name is created on the fly and is not a member of M_.endo_names.
|
||||||
[expectation_pnames, expectation_enames] = get_variables_and_parameters_in_equation(lhs, rhs, M_);
|
[expectation_pnames, ~, expectation_xnames] = get_variables_and_parameters_in_equation('', rhs, M_);
|
||||||
|
expectation_enames = get_variables_and_parameters_in_expression(lhs);
|
||||||
pnames = union(pnames, expectation_pnames);
|
pnames = union(pnames, expectation_pnames);
|
||||||
|
xnames = union(xnames, expectation_xnames);
|
||||||
enames = union(enames, expectation_enames);
|
enames = union(enames, expectation_enames);
|
||||||
enames = union(enames, lhs);
|
enames = union(enames, LHS);
|
||||||
fprintf(fid, '[name=''%s'']\n', lhs);
|
fprintf(fid, '[name=''%s'']\n', lhs);
|
||||||
fprintf(fid, '%s = %s;\n\n', lhs, rhs);
|
fprintf(fid, '%s = %s;\n\n', lhs, rhs);
|
||||||
|
else
|
||||||
|
[~, eLHS] = get_variables_and_parameters_in_equation(LHS, '', M_);
|
||||||
|
[pRHS, ~, xRHS] = get_variables_and_parameters_in_equation('', RHS, M_);
|
||||||
|
enames = union(enames, eLHS);
|
||||||
|
xnames = union(xnames, xRHS);
|
||||||
|
pnames = union(pnames, pRHS);
|
||||||
end
|
end
|
||||||
% Update pnames, enames and xnames if PAC with growth neutrality correction.
|
% Update pnames, enames and xnames if PAC with growth neutrality correction.
|
||||||
if ~isempty(ispac) && ~isempty(growthneutralitycorrection)
|
if ~isempty(ispac) && ~isempty(growthneutralitycorrection)
|
||||||
|
@ -155,7 +168,7 @@ for i=1:length(eqtags)
|
||||||
pnames = union(pnames, growthneutralitycorrection_pnames);
|
pnames = union(pnames, growthneutralitycorrection_pnames);
|
||||||
end
|
end
|
||||||
if ~isempty(growthneutralitycorrection_enames)
|
if ~isempty(growthneutralitycorrection_enames)
|
||||||
enames = union(enames, growthneutralitycorrection_enames);
|
xnames = union(xnames, growthneutralitycorrection_enames);
|
||||||
end
|
end
|
||||||
if ~isempty(growthneutralitycorrection_xnames)
|
if ~isempty(growthneutralitycorrection_xnames)
|
||||||
xnames = union(xnames, growthneutralitycorrection_xnames);
|
xnames = union(xnames, growthneutralitycorrection_xnames);
|
||||||
|
|
Loading…
Reference in New Issue