fs2000_estimation_check.inc 4.01 KB
Newer Older
1 2
%%default
options_.lik_init=1;
3
estimation(kalman_algo=0,mode_compute=8,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 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
fval_algo_0=oo_.likelihood_at_initial_parameters;
%%Multivariate Kalman Filter
options_.lik_init=1;
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;
fval_algo_1=oo_.likelihood_at_initial_parameters;
SmoothedMeasurementErrors(:,:,1)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
SmoothedShocks(:,:,1)=cell2mat(struct2cell(oo_.SmoothedShocks));
SmoothedVariables(:,:,1)=cell2mat(struct2cell(oo_.SmoothedVariables));

%%Univariate Kalman Filter
options_.lik_init=1;
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;
fval_algo_3=oo_.likelihood_at_initial_parameters;
SmoothedMeasurementErrors(:,:,3)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
SmoothedShocks(:,:,3)=cell2mat(struct2cell(oo_.SmoothedShocks));
SmoothedVariables(:,:,3)=cell2mat(struct2cell(oo_.SmoothedVariables));

%%Diffuse Multivariate Kalman Filter
options_.lik_init=1;
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;
fval_algo_2=oo_.likelihood_at_initial_parameters;
SmoothedMeasurementErrors(:,:,2)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
SmoothedShocks(:,:,2)=cell2mat(struct2cell(oo_.SmoothedShocks));
SmoothedVariables(:,:,2)=cell2mat(struct2cell(oo_.SmoothedVariables));

%%Diffuse univariate Kalman Filter
options_.lik_init=1;
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;
fval_algo_4=oo_.likelihood_at_initial_parameters;
SmoothedMeasurementErrors(:,:,4)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
SmoothedShocks(:,:,4)=cell2mat(struct2cell(oo_.SmoothedShocks));
SmoothedVariables(:,:,4)=cell2mat(struct2cell(oo_.SmoothedVariables));

37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

%%Multivariate Fast Kalman Filter
options_.lik_init=1;
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;
fval_algo_5=oo_.likelihood_at_initial_parameters;
SmoothedMeasurementErrors(:,:,5)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
SmoothedShocks(:,:,5)=cell2mat(struct2cell(oo_.SmoothedShocks));
SmoothedVariables(:,:,5)=cell2mat(struct2cell(oo_.SmoothedVariables));

%%Multivariate Fast Kalman Filter
options_.lik_init=1;
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;
fval_algo_6=oo_.likelihood_at_initial_parameters;
SmoothedMeasurementErrors(:,:,6)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors));
SmoothedShocks(:,:,6)=cell2mat(struct2cell(oo_.SmoothedShocks));
SmoothedVariables(:,:,6)=cell2mat(struct2cell(oo_.SmoothedVariables));

54

55 56 57
if max(max(abs(SmoothedMeasurementErrors-repmat(SmoothedMeasurementErrors(:,:,1),[1,1,6]))))>1e-8
    error('SmoothedMeasurementErrors do not match')
end
58

59 60 61
if max(max(abs(SmoothedShocks-repmat(SmoothedShocks(:,:,1),[1,1,6]))))>1e-8
    error('SmoothedShocks do not match')
end
62

63 64 65
if max(max(abs(SmoothedVariables-repmat(SmoothedVariables(:,:,1),[1,1,6]))))>1e-8
    error('SmoothedVariables do not match')
end
66

67 68
if max(abs([fval_algo_2,fval_algo_3,fval_algo_4,fval_algo_5,fval_algo_6]-fval_algo_1))>1e-6
    error('Likelihoods do not match')
69
end