Debian Codegraph @

tests/kalman_skewed/ireland2004_bayes.mod

raw
1 % Various tests within Bayesian MCMC estimation
2 % with skew normally distributed shocks
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 OMEGA = 0.1377;
25 RHO_PI = 0.4522;
26 RHO_G = 0.3445;
27 RHO_X = 0.2006;
28 RHO_A = 0.9336;
29 RHO_E = 0.9153;
30
31 shocks;
32 var eta_a; stderr 3.2442;
33 var eta_e; stderr 0.0573;
34 var eta_z; stderr 0.7546;
35 var eta_r; stderr 0.2775;
36 skew eta_a = -0.1925;
37 skew eta_e = -0.4014;
38 skew eta_z = -0.5166;
39 skew eta_r = +0.6066;
40 end;
41
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 % TEST 1: declaring skewed shocks in different ways in a Bayesian estimation should work %
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 estimated_params;
46 stderr eta_a, , 0, 10, inv_gamma_pdf, (sqrt(30)), (sqrt(30)) ;
47 stderr eta_e, , 0, 10, inv_gamma_pdf, (sqrt(0.08)), (sqrt(1)) ;
48 stderr eta_z, , 0, 10, inv_gamma_pdf, (sqrt(5)), (sqrt(15)) ;
49 stderr eta_r, , 0, 10, inv_gamma_pdf, (sqrt(0.50)), (sqrt(2)) ;
50 OMEGA, , 0, 1, beta_pdf, 0.20, 0.10 ;
51 RHO_PI, , 0, 1, gamma_pdf, 0.30, 0.10 ;
52 RHO_G, , 0, 1, gamma_pdf, 0.30, 0.10 ;
53 RHO_X, , 0, 1, gamma_pdf, 0.25, 0.0625 ;
54 RHO_A, , 0, 1, beta_pdf, 0.85, 0.10 ;
55 RHO_E, , 0, 1, beta_pdf, 0.85, 0.10 ;
56 skew eta_a, beta_pdf, 0, 0.40 , -1, 1;
57 skew eta_e, 0.4, -0.8, 0.9, beta_pdf, 0, 0.40 , -1, 1;
58 skew eta_z, , , , beta_pdf, 0, 0.40 , -1, 1;
59 skew eta_r, , -0.9, 0.8, uniform_pdf, , , -1, 1;
60 end;
61
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 % TEST 2: estimated_params_init, estimated_params_remove blocks should work %
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 estimated_params_init(use_calibration);
66 end;
67
68 estimated_params_remove;
69 stderr eta_a;
70 stderr eta_z;
71 stderr eta_r;
72 OMEGA;
73 RHO_PI;
74 RHO_G;
75 RHO_A;
76 RHO_E;
77 skew eta_a;
78 skew eta_z;
79 skew eta_r;
80 end;
81
82 estimated_params_init;
83 RHO_X, 0.200410549459701;
84 stderr eta_e, 0.057271868850671;
85 skew eta_e, -0.399902738406484;
86 end;
87
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 % TEST 3: Bayesian estimation with RWMH sampler should work without error %
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 estimation(datafile = 'ireland2004_post1980.csv'
92 , mode_compute = 4, silent_optimizer
93 , lik_init = 1
94 , mh_replic = 250
95 , mh_nblocks = 1
96 , plot_priors = 0
97 , kalman_algo = 5 % use pruned skewed Kalman filter
98 , skewed_kalman_prune_tol = 0.2 % set extremely high for speed in testsuite
99 , mh_jscale = 10
100 , tex
101 );
102
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 % TEST 4: trace plots and autocorrelation functions should be computed %
105 % and plotted for skewness coefficients of structural shocks %
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 generate_trace_plots(1);
108 trace_plot(options_,M_,estim_params_,'StructuralShock',1,'eta_e','eta_e','eta_e');
109 mh_autocorrelation_function(options_,M_,estim_params_,'StructuralShock',1,'eta_e','eta_e','eta_e');