Debian Codegraph @

tests/estimation/method_of_moments/CET/cet_irf_matching_file.m

raw
1 function [modelIrf, error_indicator] = cet_irf_matching_file(modelIrf, M_, options_mom_, ys_)
2 % [modelIrf, error_indicator] = cet_irf_matching_file(modelIrf, M_, options_mom_, ys_)
3 % -------------------------------------------------------------------------
4 % This file manipulates model IRFs to be consistent with empirical IRFS
5 % -------------------------------------------------------------------------
6 % INPUTS
7 % - modelIrf: [options_mom_.irf by M_.endo_nbr by M_.exo_nbr]
8 % array of IRFs for all model variables and all shocks
9 % - M_: [structure] Dynare model structure
10 % - options_mom_: [structure] Dynare options structure
11 % - ys_: [double] steady state values of all endogenous variables
12 % -------------------------------------------------------------------------
13 % OUTPUTS
14 % - modelIrf: [options_mom_.irf by M_.endo_nbr by M_.exo_nbr]
15 % modified array of IRFs for all model variables and all shocks
16 % - error_indicator: [boolean] indicator of success (0) or failure (1)
17 % -------------------------------------------------------------------------
18 % This function is called by
19 % - mom.run
20 % -------------------------------------------------------------------------
21
22 % Copyright © 2023 Dynare Team
23 %
24 % This file is part of Dynare.
25 %
26 % Dynare is free software: you can redistribute it and/or modify
27 % it under the terms of the GNU General Public License as published by
28 % the Free Software Foundation, either version 3 of the License, or
29 % (at your option) any later version.
30 %
31 % Dynare is distributed in the hope that it will be useful,
32 % but WITHOUT ANY WARRANTY; without even the implied warranty of
33 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 % GNU General Public License for more details.
35 %
36 % You should have received a copy of the GNU General Public License
37 % along with Dynare. If not, see <https://www.gnu.org/licenses/>.
38
39 % initialize error indicator
40 error_indicator = 0;
41
42 % get indices of variables
43 idmuF = ismember(M_.endo_names,'muF');
44 idmupsiF = ismember(M_.endo_names,'mupsiF');
45 idGDPAGG = ismember(M_.endo_names,'GDPAGG');
46 idpiAGG = ismember(M_.endo_names,'piAGG');
47 idRAGG = ismember(M_.endo_names,'RAGG');
48 idukAGG = ismember(M_.endo_names,'ukAGG');
49 idlAGG = ismember(M_.endo_names,'lAGG');
50 idwAGG = ismember(M_.endo_names,'wAGG');
51 idcAGG = ismember(M_.endo_names,'cAGG');
52 idiAGG = ismember(M_.endo_names,'iAGG');
53 idpinvestAGG = ismember(M_.endo_names,'pinvestAGG');
54 idpunempAGG = ismember(M_.endo_names,'unempAGG');
55 idvTotAGG = ismember(M_.endo_names,'vTotAGG');
56 idfAGG = ismember(M_.endo_names,'fAGG');
57
58 modelIrf = 100.*modelIrf; % convert to percent deviations
59 for jexo=1:M_.exo_nbr
60 if jexo==1
61 mulev_vec = 0;
62 mupsilev_vec = 0;
63 else
64 mulev_vec = cumsum(modelIrf(:,idmuF,jexo));
65 mupsilev_vec = cumsum(modelIrf(:,idmupsiF,jexo));
66 end
67 modelIrf(:,idGDPAGG,jexo) = modelIrf(:,idGDPAGG,jexo) + mulev_vec; % gdp = GDPAGG + cumsum(muF)
68 modelIrf(:,idpiAGG,jexo) = modelIrf(:,idpiAGG,jexo); % inflation = piAGG
69 modelIrf(:,idRAGG,jexo) = modelIrf(:,idRAGG,jexo); % Nominal interest rate = RAGG
70 modelIrf(:,idukAGG,jexo) = modelIrf(:,idukAGG,jexo); % capital utilization = ukAGG
71 modelIrf(:,idlAGG,jexo) = modelIrf(:,idlAGG,jexo); % labor = lAGG
72 modelIrf(:,idwAGG,jexo) = modelIrf(:,idwAGG,jexo) + mulev_vec; % real wage = wAGG + cumsum(muF)
73 modelIrf(:,idcAGG,jexo) = modelIrf(:,idcAGG,jexo) + mulev_vec; % consumption = cAGG + cumsum(muF)
74 modelIrf(:,idiAGG,jexo) = modelIrf(:,idiAGG,jexo) + mulev_vec + mupsilev_vec; % investment = iAGG + cumsum(muF) + cumsum(mupsiF)
75 modelIrf(:,idpinvestAGG,jexo) = cumsum(modelIrf(:,idpinvestAGG,jexo)); % rel. price investment = cumsum(pinvestAGG)
76 modelIrf(:,idpunempAGG,jexo) = modelIrf(:,idpunempAGG,jexo)*M_.params(ismember(M_.param_names,'u')); % vacancies = vTotAGG*u
77 modelIrf(:,idvTotAGG,jexo) = modelIrf(:,idvTotAGG,jexo); % aggregated total vacancies = vTotAGG
78 modelIrf(:,idfAGG,jexo) = modelIrf(:,idfAGG,jexo)*M_.params(ismember(M_.param_names,'f')); % job finding rate = fAGG*f
79 end