Debian Codegraph @

tests/kalman_skewed/skew_in_estimated_params.mod

raw
1 % Tests for preprocessor capabilities of skew in estimated_params blocks
2 % Note: manual tests for error messages by uncommenting specific lines
3 % -------------------------------------------------------------------------
4
5 % Copyright © 2025 Dynare Team
6 %
7 % This file is part of Dynare.
8 %
9 % Dynare is free software: you can redistribute it and/or modify
10 % it under the terms of the GNU General Public License as published by
11 % the Free Software Foundation, either version 3 of the License, or
12 % (at your option) any later version.
13 %
14 % Dynare is distributed in the hope that it will be useful,
15 % but WITHOUT ANY WARRANTY; without even the implied warranty of
16 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 % GNU General Public License for more details.
18 %
19 % You should have received a copy of the GNU General Public License
20 % along with Dynare. If not, see <https://www.gnu.org/licenses/>.
21
22 @#include "ireland2004_model.inc"
23
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 % TEST 1: check estim_params with concatenating %
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28 estimated_params;
29 skew eta_a, normal_pdf, 1, 0.10, 0.11, 1.11, 111;
30 skew eta_e, 2.22, 2.00, 22.22, beta_pdf, 2, 0.22;
31 skew eta_r, gamma_pdf, 3, 0.30;
32 %skew yhat, inv_gamma_pdf, 5, 0.50; % triggers error because variable cannot be endogenous (yhat)
33 %skew eta_u, normal_pdf, 38, 0.38; % triggers error because of undeclared eta_u
34 %skew ALPHA_PI, normal_pdf, 38, 0.38; % triggers error because variable cannot be parameter (ALPHA_PI)
35 end;
36
37 fprintf('\nPreprocessing of estimated_params block...\n')
38 fprintf('%s estim_params_.skew_exo %s\n\n', repmat('=',1,40), repmat('=',1,40));
39 disp(estim_params_.skew_exo)
40 fprintf('%s\n', repmat('=',1,104));
41
42 skew_exo = [
43 1 nan -Inf Inf 3 1 0.10 0.11 1.11 111;
44 2 2.22 2 22.22 1 2 0.22 nan nan nan;
45 4 nan -Inf Inf 2 3 0.30 nan nan nan;
46 ];
47 if ~isequaln(skew_exo, estim_params_.skew_exo)
48 error('estim_params block is preprocessed incorrectly');
49 else
50 fprintf('...successful!\n')
51 end
52
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 % TEST 2: check estimated_params_init %
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 estimated_params_init;
57 skew eta_a, 555;
58 skew eta_e, 222;
59 skew eta_z, 666; % displays message: The skewness of eta_z is not estimated (the value provided in estimated_params_init is not used).
60 end;
61
62 skew_exo(1, 2) = 555;
63 skew_exo(2, 2) = 222;
64
65 fprintf('\nPreprocessing of estimated_params_init block...\n')
66 fprintf('%s estim_params_.skew_exo %s\n\n', repmat('=',1,40), repmat('=',1,40));
67 disp(estim_params_.skew_exo)
68 fprintf('%s\n', repmat('=',1,104));
69 if ~isequaln(skew_exo, estim_params_.skew_exo)
70 error('estimated_params_init block is preprocessed incorrectly');
71 else
72 fprintf('...successful!\n')
73 end
74
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 % TEST 3: check estimated_params_bounds %
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 estimated_params_bounds;
79 skew eta_a, 5, 55;
80 skew eta_e, 2, 22;
81 end;
82
83 skew_exo(1, [3 4]) = [5 55];
84 skew_exo(2, [3 4]) = [2 22];
85
86 fprintf('\nPreprocessing of estimated_params_bounds block...\n')
87 fprintf('%s estim_params_.skew_exo %s\n\n', repmat('=',1,40), repmat('=',1,40));
88 disp(estim_params_.skew_exo)
89 fprintf('%s\n', repmat('=',1,104));
90 if ~isequaln(skew_exo, estim_params_.skew_exo)
91 error('estimated_params_bounds block is preprocessed incorrectly');
92 else
93 fprintf('...successful!\n')
94 end
95
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 % TEST 4: check estimated_params_remove %
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99 estimated_params_remove;
100 skew eta_e;
101 end;
102
103 skew_exo(2,:) = [];
104
105 fprintf('\nPreprocessing of estimated_params_remove block...\n')
106 fprintf('%s estim_params_.skew_exo %s\n\n', repmat('=',1,40), repmat('=',1,40));
107 disp(estim_params_.skew_exo)
108 fprintf('%s\n', repmat('=',1,104));
109 if ~isequaln(skew_exo, estim_params_.skew_exo)
110 error('estimated_params_remove block is preprocessed incorrectly');
111 else
112 fprintf('...successful!\n')
113 end
114
115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 % TEST 5: check estimated_params(overwrite) %
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 estimated_params(overwrite);
119 skew eta_z, inv_gamma_pdf, 4, 0.40;
120 end;
121 skew_exo = [3, nan, -Inf, Inf, 4, 4, 0.40, nan, nan, nan];
122
123 fprintf('\nPreprocessing of estim_params(overwrite) block...\n')
124 fprintf('%s estim_params_.skew_exo %s\n\n', repmat('=',1,40), repmat('=',1,40));
125 disp(estim_params_.skew_exo)
126 fprintf('%s\n', repmat('=',1,104));
127 if ~isequaln(skew_exo, estim_params_.skew_exo)
128 error('estim_params(overwrite) block is preprocessed incorrectly');
129 else
130 fprintf('...successful!\n')
131 end