| 1 |
%%get mode |
| 2 |
estimation(diffuse_filter,kalman_algo=3,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; |
| 3 |
fval_algo_0=oo_.likelihood_at_initial_parameters; |
| 4 |
|
| 5 |
%%Diffuse Multivariate Kalman Filter |
| 6 |
options_.lik_init=1; |
| 7 |
estimation(kalman_algo=3,diffuse_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; |
| 8 |
fval_algo_2=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 |
%%Diffuse univariate Kalman Filter |
| 14 |
options_.lik_init=1; |
| 15 |
estimation(kalman_algo=4,diffuse_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; |
| 16 |
fval_algo_4=oo_.likelihood_at_initial_parameters; |
| 17 |
SmoothedMeasurementErrors(:,:,2)=cell2mat(struct2cell(oo_.SmoothedMeasurementErrors)); |
| 18 |
SmoothedShocks(:,:,2)=cell2mat(struct2cell(oo_.SmoothedShocks)); |
| 19 |
SmoothedVariables(:,:,2)=cell2mat(struct2cell(oo_.SmoothedVariables)); |
| 20 |
|
| 21 |
if max(max(abs(SmoothedMeasurementErrors-repmat(SmoothedMeasurementErrors(:,:,1),[1,1,2]))))>1e-8 |
| 22 |
error('SmoothedMeasurementErrors do not match') |
| 23 |
end |
| 24 |
|
| 25 |
if max(max(abs(SmoothedShocks-repmat(SmoothedShocks(:,:,1),[1,1,2]))))>1e-8 |
| 26 |
error('SmoothedShocks do not match') |
| 27 |
end |
| 28 |
|
| 29 |
if isoctave |
| 30 |
tol_crit=5e-6; |
| 31 |
else |
| 32 |
tol_crit=1e-8; |
| 33 |
end |
| 34 |
|
| 35 |
if max(max(abs(SmoothedVariables-repmat(SmoothedVariables(:,:,1),[1,1,2]))))>tol_crit |
| 36 |
error('SmoothedVariables do not match') |
| 37 |
end |
| 38 |
|
| 39 |
if max(abs(fval_algo_2-fval_algo_4))>1e-6 |
| 40 |
fprintf('\nLikelihood difference: %4.3f\n',max(abs(fval_algo_2-fval_algo_4))) |
| 41 |
error('Likelihoods do not match') |
| 42 |
end |