Debian Codegraph @

tests/kalman/likelihood_from_dynare/fs2000_estimation_check.inc

raw
1 %%default
2 options_.lik_init=1;
3 estimation(kalman_algo=0,silent_optimizer,mode_compute=4,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;
4 fval_algo_0=oo_.likelihood_at_initial_parameters;
5 %%Multivariate Kalman Filter
6 options_.lik_init=1;
7 estimation(kalman_algo=1,mode_file=@{mode_file_name},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;
8 fval_algo_1=oo_.likelihood_at_initial_parameters;
9 SmoothedMeasurementErrors(:,:,1)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
10 SmoothedShocks(:,:,1)=cell2mat(struct2cell(oo_.SmoothedShocks));
11 SmoothedVariables(:,:,1)=cell2mat(struct2cell(oo_.SmoothedVariables));
12
13 %%Univariate Kalman Filter
14 options_.lik_init=1;
15 estimation(kalman_algo=3,mode_file=@{mode_file_name},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;
16 fval_algo_3=oo_.likelihood_at_initial_parameters;
17 SmoothedMeasurementErrors(:,:,3)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
18 SmoothedShocks(:,:,3)=cell2mat(struct2cell(oo_.SmoothedShocks));
19 SmoothedVariables(:,:,3)=cell2mat(struct2cell(oo_.SmoothedVariables));
20
21 %%Diffuse Multivariate Kalman Filter
22 options_.lik_init=1;
23 estimation(kalman_algo=2,mode_file=@{mode_file_name},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;
24 fval_algo_2=oo_.likelihood_at_initial_parameters;
25 SmoothedMeasurementErrors(:,:,2)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
26 SmoothedShocks(:,:,2)=cell2mat(struct2cell(oo_.SmoothedShocks));
27 SmoothedVariables(:,:,2)=cell2mat(struct2cell(oo_.SmoothedVariables));
28
29 %%Diffuse univariate Kalman Filter
30 options_.lik_init=1;
31 estimation(kalman_algo=4,mode_file=@{mode_file_name},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;
32 fval_algo_4=oo_.likelihood_at_initial_parameters;
33 SmoothedMeasurementErrors(:,:,4)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
34 SmoothedShocks(:,:,4)=cell2mat(struct2cell(oo_.SmoothedShocks));
35 SmoothedVariables(:,:,4)=cell2mat(struct2cell(oo_.SmoothedVariables));
36
37
38 %%Multivariate Fast Kalman Filter
39 options_.lik_init=1;
40 estimation(kalman_algo=1,fast_kalman_filter,mode_file=@{mode_file_name},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;
41 fval_algo_5=oo_.likelihood_at_initial_parameters;
42 SmoothedMeasurementErrors(:,:,5)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
43 SmoothedShocks(:,:,5)=cell2mat(struct2cell(oo_.SmoothedShocks));
44 SmoothedVariables(:,:,5)=cell2mat(struct2cell(oo_.SmoothedVariables));
45
46 %%Multivariate Fast Kalman Filter
47 options_.lik_init=1;
48 estimation(kalman_algo=3,fast_kalman_filter,mode_file=@{mode_file_name},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;
49 fval_algo_6=oo_.likelihood_at_initial_parameters;
50 SmoothedMeasurementErrors(:,:,6)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
51 SmoothedShocks(:,:,6)=cell2mat(struct2cell(oo_.SmoothedShocks));
52 SmoothedVariables(:,:,6)=cell2mat(struct2cell(oo_.SmoothedVariables));
53
54
55 if max(max(abs(SmoothedMeasurementErrors-repmat(SmoothedMeasurementErrors(:,:,1),[1,1,6]))))>1e-6
56 error('SmoothedMeasurementErrors do not match')
57 end
58
59 if max(max(abs(SmoothedShocks-repmat(SmoothedShocks(:,:,1),[1,1,6]))))>1e-6
60 error('SmoothedShocks do not match')
61 end
62
63 if max(max(abs(SmoothedVariables-repmat(SmoothedVariables(:,:,1),[1,1,6]))))>1e-6
64 error('SmoothedVariables do not match')
65 end
66
67 if max(abs([fval_algo_2,fval_algo_3,fval_algo_4,fval_algo_5,fval_algo_6]-fval_algo_1))>1e-6
68 error('Likelihoods do not match')
69 end