Select Git revision
backward_model_inversion.m
backward_model_inversion.m 5.51 KiB
function [endogenousvariables, exogenousvariables] = backward_model_inversion(constraints, exogenousvariables, initialconditions, endo_names, exo_names, freeinnovations, DynareModel, DynareOptions, DynareOutput)
% INPUTS
% - constraints [dseries] with N constrained endogenous variables from t1 to t2.
% - exogenousvariables [dseries] with Q exogenous variables.
% - initialconditions [dseries] with M endogenous variables starting before t1 (M initialcond must contain at least the state variables).
% - endo_names [cell] list of endogenous variable names.
% - exo_names [cell] list of exogenous variable names.
% - freeinstruments [cell] list of exogenous variable names used to control the constrained endogenous variables.
%
% OUTPUTS
% - endogenous [dseries]
% - exogenous [dseries]
%
% REMARKS
% Copyright (C) 2017 Dynare Team
%
% 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
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% Get indices for the calibrated and free innovations.
freeinnovations_id = zeros(length(freeinnovations), 1);
if length(freeinnovations)<DynareModel.exo_nbr
for i=1:length(freeinnovations)
freeinnovations_id(i) = find(strcmp(freeinnovations{i}, exo_names));
end
calibratedinnovations_id = setdiff(transpose(1:length(exo_names)), freeinnovations_id);
else
freeinnovations_id = transpose(1:length(exo_names));
calibratedinnovations_id = [];
end
nxfree = length(freeinnovations_id);
nxcalb = length(calibratedinnovations_id);
% Get indices for the the controlled and free endogenous variables.
controlledendogenousvariables_id = zeros(length(freeinnovations), 1);
if length(freeinnovations)<DynareModel.endo_nbr
for i=1:length(freeinnovations)
controlledendogenousvariables_id(i) = find(strcmp(constraints.name{i}, endo_names));
end
freeendogenousvariables_id = setdiff(transpose(1:length(endo_names)), controlledendogenousvariables_id);
else
controlledendogenousvariables_id = transpose(1:length(endo_names));
freeendogenousvariables_id = [];
end
nyfree = length(freeendogenousvariables_id);
nyctrl = length(controlledendogenousvariables_id);
% Get indices of variables appearing at time t-1.
iy1 = find(DynareModel.lead_lag_incidence(1,:)>0);
% Get indices of variables appearing at time t.
iy0 = find(DynareModel.lead_lag_incidence(2,:)>0);
% Set indices for trust_region algorithm.