Debian Codegraph @

tests/kalman/likelihood_from_dynare/fs2000_uncorr_ME_missing.mod

raw
1 @#include "fs2000_model.inc"
2
3 estimated_params;
4 alp, 0.356;
5 gam, 0.0085;
6 del, 0.01;
7 stderr e_a, 0.035449;
8 stderr e_m, 0.008862;
9 corr e_m, e_a, 0;
10 stderr gp_obs, 1;
11 stderr gy_obs, 1;
12 //corr gp_obs, gy_obs,0;
13 end;
14
15 @#define data_file_name="fsdat_simul_uncorr_ME_missing"
16
17 %%default
18 options_.lik_init=1;
19 estimation(kalman_algo=0,mode_compute=0,order=1,datafile=@{data_file_name},smoother,filter_decomposition,forecast = 8,filtered_vars,filter_step_ahead=[1,3],irf=20) m P c e W R k d y gy_obs;
20 fval_algo_0=oo_.likelihood_at_initial_parameters;
21 %%Multivariate Kalman Filter
22 options_.lik_init=1;
23 estimation(kalman_algo=1,mode_compute=0,order=1,datafile=@{data_file_name},smoother,filter_decomposition,forecast = 8,filtered_vars,filter_step_ahead=[1,3],irf=20) m P c e W R k d y gy_obs;
24 fval_algo_1=oo_.likelihood_at_initial_parameters;
25 SmoothedMeasurementErrors(:,:,1)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
26 SmoothedShocks(:,:,1)=cell2mat(struct2cell(oo_.SmoothedShocks));
27 SmoothedVariables(:,:,1)=cell2mat(struct2cell(oo_.SmoothedVariables));
28
29 %%Univariate Kalman Filter
30 options_.lik_init=1;
31 estimation(kalman_algo=3,mode_compute=0,order=1,datafile=@{data_file_name},smoother,filter_decomposition,forecast = 8,filtered_vars,filter_step_ahead=[1,3],irf=20) m P c e W R k d y gy_obs;
32 fval_algo_3=oo_.likelihood_at_initial_parameters;
33 SmoothedMeasurementErrors(:,:,3)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
34 SmoothedShocks(:,:,3)=cell2mat(struct2cell(oo_.SmoothedShocks));
35 SmoothedVariables(:,:,3)=cell2mat(struct2cell(oo_.SmoothedVariables));
36
37 %%Diffuse Multivariate Kalman Filter
38 options_.lik_init=1;
39 estimation(kalman_algo=2,mode_compute=0,datafile=@{data_file_name},smoother,filter_decomposition,forecast = 8,filtered_vars,filter_step_ahead=[1,3],irf=20) m P c e W R k d y gy_obs;
40 fval_algo_2=oo_.likelihood_at_initial_parameters;
41 SmoothedMeasurementErrors(:,:,2)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
42 SmoothedShocks(:,:,2)=cell2mat(struct2cell(oo_.SmoothedShocks));
43 SmoothedVariables(:,:,2)=cell2mat(struct2cell(oo_.SmoothedVariables));
44
45 %%Diffuse univariate Kalman Filter
46 options_.lik_init=1;
47 estimation(kalman_algo=4,mode_compute=0,datafile=@{data_file_name},smoother,filter_decomposition,forecast = 8,filtered_vars,filter_step_ahead=[1,3],irf=20) m P c e W R k d y gy_obs;
48 fval_algo_4=oo_.likelihood_at_initial_parameters;
49 SmoothedMeasurementErrors(:,:,4)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
50 SmoothedShocks(:,:,4)=cell2mat(struct2cell(oo_.SmoothedShocks));
51 SmoothedVariables(:,:,4)=cell2mat(struct2cell(oo_.SmoothedVariables));
52
53
54 %%Multivariate Fast Kalman Filter
55 options_.lik_init=1;
56 estimation(kalman_algo=1,fast_kalman_filter,mode_compute=0,order=1,datafile=@{data_file_name},smoother,filter_decomposition,forecast = 8,filtered_vars,filter_step_ahead=[1,3],irf=20) m P c e W R k d y gy_obs;
57 fval_algo_5=oo_.likelihood_at_initial_parameters;
58 SmoothedMeasurementErrors(:,:,5)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
59 SmoothedShocks(:,:,5)=cell2mat(struct2cell(oo_.SmoothedShocks));
60 SmoothedVariables(:,:,5)=cell2mat(struct2cell(oo_.SmoothedVariables));
61
62 %%Multivariate Fast Kalman Filter
63 options_.lik_init=1;
64 estimation(kalman_algo=3,fast_kalman_filter,mode_compute=0,order=1,datafile=@{data_file_name},smoother,filter_decomposition,forecast = 8,filtered_vars,filter_step_ahead=[1,3],irf=20) m P c e W R k d y gy_obs;
65 fval_algo_6=oo_.likelihood_at_initial_parameters;
66 SmoothedMeasurementErrors(:,:,6)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
67 SmoothedShocks(:,:,6)=cell2mat(struct2cell(oo_.SmoothedShocks));
68 SmoothedVariables(:,:,6)=cell2mat(struct2cell(oo_.SmoothedVariables));
69
70
71 if max(max(abs(SmoothedMeasurementErrors-repmat(SmoothedMeasurementErrors(:,:,1),[1,1,6]))))>1e-8
72 error('SmoothedMeasurementErrors do not match')
73 end
74
75 if max(max(abs(SmoothedShocks-repmat(SmoothedShocks(:,:,1),[1,1,6]))))>1e-8
76 error('SmoothedShocks do not match')
77 end
78
79 if max(max(abs(SmoothedVariables-repmat(SmoothedVariables(:,:,1),[1,1,6]))))>1e-8
80 error('SmoothedVariables do not match')
81 end
82
83 if max(abs([fval_algo_2,fval_algo_3,fval_algo_4,fval_algo_5,fval_algo_6]-fval_algo_1))>1e-8
84 error('Likelihoods do not match')
85 end