Particle filtering: provide more informative error messages in typical problematic cases
Also adds test casestime-shift
parent
fe93589148
commit
ad17b8ec33
|
@ -166,6 +166,8 @@ switch info(1)
|
||||||
message = 'Aim: A is NAN or INF.';
|
message = 'Aim: A is NAN or INF.';
|
||||||
case 164
|
case 164
|
||||||
message = 'Aim: Problem in SPEIG.';
|
message = 'Aim: Problem in SPEIG.';
|
||||||
|
case 201
|
||||||
|
message = 'Particle Filter: Initial covariance of the states is not positive definite. Try a different nonlinear_filter_initialization';
|
||||||
otherwise
|
otherwise
|
||||||
message = 'This case shouldn''t happen. Contact the authors of Dynare';
|
message = 'This case shouldn''t happen. Contact the authors of Dynare';
|
||||||
end
|
end
|
|
@ -51,6 +51,14 @@ if DynareOptions.order>1
|
||||||
if BayesInfo.with_trend
|
if BayesInfo.with_trend
|
||||||
error('initial_estimation_checks:: particle filtering does not support trends')
|
error('initial_estimation_checks:: particle filtering does not support trends')
|
||||||
end
|
end
|
||||||
|
if Model.H==0
|
||||||
|
error('initial_estimation_checks:: particle filtering requires measurement error on the observables')
|
||||||
|
else
|
||||||
|
[~,flag]=chol(Model.H);
|
||||||
|
if flag
|
||||||
|
error('initial_estimation_checks:: the measurement error matrix must be positive definite')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
non_zero_ME=length(EstimatedParameters.H_entries_to_check_for_positive_definiteness);
|
non_zero_ME=length(EstimatedParameters.H_entries_to_check_for_positive_definiteness);
|
||||||
|
@ -152,6 +160,10 @@ if ~isequal(DynareOptions.mode_compute,11) || ...
|
||||||
fprintf('initial_estimation_checks:: If you think the latter is the case, you should try with different initial values for the estimated parameters.\n')
|
fprintf('initial_estimation_checks:: If you think the latter is the case, you should try with different initial values for the estimated parameters.\n')
|
||||||
error('initial_estimation_checks:: The forecast error variance in the multivariate Kalman filter became singular.')
|
error('initial_estimation_checks:: The forecast error variance in the multivariate Kalman filter became singular.')
|
||||||
end
|
end
|
||||||
|
if info(1)==201
|
||||||
|
fprintf('initial_estimation_checks:: Initial covariance of the states is not positive definite. Try a different nonlinear_filter_initialization.\n')
|
||||||
|
error('initial_estimation_checks:: Initial covariance of the states is not positive definite. Try a different nonlinear_filter_initialization.')
|
||||||
|
end
|
||||||
%reset options
|
%reset options
|
||||||
DynareOptions.use_univariate_filters_if_singularity_is_detected=use_univariate_filters_if_singularity_is_detected_old;
|
DynareOptions.use_univariate_filters_if_singularity_is_detected=use_univariate_filters_if_singularity_is_detected_old;
|
||||||
else
|
else
|
||||||
|
|
|
@ -158,6 +158,14 @@ end
|
||||||
ReducedForm.StateVectorMean = StateVectorMean;
|
ReducedForm.StateVectorMean = StateVectorMean;
|
||||||
ReducedForm.StateVectorVariance = StateVectorVariance;
|
ReducedForm.StateVectorVariance = StateVectorVariance;
|
||||||
|
|
||||||
|
[~, flag] = chol(ReducedForm.StateVectorVariance);%reduced_rank_cholesky(ReducedForm.StateVectorVariance)';
|
||||||
|
if flag
|
||||||
|
fval = Inf;
|
||||||
|
info(1) = 201;
|
||||||
|
info(4) = 0.1;
|
||||||
|
exit_flag = 0;
|
||||||
|
return;
|
||||||
|
end
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
% 4. Likelihood evaluation
|
% 4. Likelihood evaluation
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
|
|
|
@ -417,6 +417,7 @@ MODFILES = \
|
||||||
bgp/nk-1/nk.mod \
|
bgp/nk-1/nk.mod \
|
||||||
bgp/ramsey-1/ramsey.mod \
|
bgp/ramsey-1/ramsey.mod \
|
||||||
dynare-command-options/ramst.mod \
|
dynare-command-options/ramst.mod \
|
||||||
|
particle/first_spec.mod \
|
||||||
particle/local_state_space_iteration_k_test.mod
|
particle/local_state_space_iteration_k_test.mod
|
||||||
|
|
||||||
ECB_MODFILES = \
|
ECB_MODFILES = \
|
||||||
|
@ -558,6 +559,8 @@ XFAIL_MODFILES = ramst_xfail.mod \
|
||||||
identification/LindeTrabandt/LindeTrabandt2019_xfail.mod \
|
identification/LindeTrabandt/LindeTrabandt2019_xfail.mod \
|
||||||
steady_state/Linear_steady_state_xfail.mod \
|
steady_state/Linear_steady_state_xfail.mod \
|
||||||
optimal_policy/Ramsey/ramsey_histval_xfail.mod \
|
optimal_policy/Ramsey/ramsey_histval_xfail.mod \
|
||||||
|
particle/first_spec_xfail_0.mod \
|
||||||
|
particle/first_spec_xfail_1.mod \
|
||||||
example1_extra_exo_xfail.mod \
|
example1_extra_exo_xfail.mod \
|
||||||
estimation/tune_mh_jscale/fs2000_1_xfail.mod \
|
estimation/tune_mh_jscale/fs2000_1_xfail.mod \
|
||||||
estimation/tune_mh_jscale/fs2000_2_xfail.mod
|
estimation/tune_mh_jscale/fs2000_2_xfail.mod
|
||||||
|
@ -1150,6 +1153,7 @@ EXTRA_DIST = \
|
||||||
shock_decomposition/example1_calib_shock_decomp_data.mat \
|
shock_decomposition/example1_calib_shock_decomp_data.mat \
|
||||||
shock_decomposition/fsdat_simul.m \
|
shock_decomposition/fsdat_simul.m \
|
||||||
smoother2histval/fsdat_simul.m \
|
smoother2histval/fsdat_simul.m \
|
||||||
|
particle/first_spec_common.inc \
|
||||||
optimal_policy/Ramsey/find_c.m \
|
optimal_policy/Ramsey/find_c.m \
|
||||||
optimal_policy/Ramsey/oo_ramsey_policy_initval.mat \
|
optimal_policy/Ramsey/oo_ramsey_policy_initval.mat \
|
||||||
observation_trends_and_prefiltering/generate_trend_stationary_AR1.m \
|
observation_trends_and_prefiltering/generate_trend_stationary_AR1.m \
|
||||||
|
|
|
@ -113,5 +113,7 @@ end;
|
||||||
|
|
||||||
data(file='../../fs2000/fsdat_simul.m');
|
data(file='../../fs2000/fsdat_simul.m');
|
||||||
|
|
||||||
|
options_.order=1;
|
||||||
|
|
||||||
[dataset_, dataset_info, xparam1, hh, M_, options_, oo_, estim_params_, bayestopt_, bounds] = ...
|
[dataset_, dataset_info, xparam1, hh, M_, options_, oo_, estim_params_, bayestopt_, bounds] = ...
|
||||||
dynare_estimation_init(char(), M_.fname, [], M_, options_, oo_, estim_params_, bayestopt_);
|
dynare_estimation_init(char(), M_.fname, [], M_, options_, oo_, estim_params_, bayestopt_);
|
|
@ -0,0 +1,16 @@
|
||||||
|
//File testing error message if initial state vector is not positive definite
|
||||||
|
|
||||||
|
@#include "first_spec_common.inc"
|
||||||
|
|
||||||
|
shocks;
|
||||||
|
var eeps = 0.04^2;
|
||||||
|
var nnu = 0.03^2;
|
||||||
|
var q = 0.01^2;
|
||||||
|
var ca = 0.01^2;
|
||||||
|
end;
|
||||||
|
|
||||||
|
stoch_simul(order=3,periods=200, irf=0);
|
||||||
|
|
||||||
|
save('my_data.mat','q','ca');
|
||||||
|
|
||||||
|
estimation(datafile='my_data.mat',order=2,mode_compute=0,mh_replic=1,filter_algorithm=sis,nonlinear_filter_initialization=2);
|
|
@ -0,0 +1,48 @@
|
||||||
|
var c q m b u R uaux ca;
|
||||||
|
|
||||||
|
varexo eeps nnu;
|
||||||
|
|
||||||
|
parameters bbetaL ies crra gbar bbar eeta Rbar Rpers;
|
||||||
|
|
||||||
|
bbetaL = 0.98;
|
||||||
|
ies = 1.5;
|
||||||
|
crra = 12.0;
|
||||||
|
gbar = .01;
|
||||||
|
bbar = -.04;
|
||||||
|
eeta = 2.0;
|
||||||
|
Rbar = 1.03;
|
||||||
|
Rpers = .5;
|
||||||
|
|
||||||
|
model;
|
||||||
|
|
||||||
|
q = m(+1)*R(+1);
|
||||||
|
uaux = u(+1)^(1-crra);
|
||||||
|
m = bbetaL*exp(-gbar/ies)*uaux(-1)^((ies-1)/(ies*(1-crra))-1)*u^(1/ies-crra)*c^(-1/ies)/c(-1)^(-1/ies);
|
||||||
|
b = bbar*q^eeta*exp(nnu);
|
||||||
|
c + q*b*exp(gbar) = 1 + R*b(-1);
|
||||||
|
u = ( (1-bbetaL)*c^((ies-1)/ies) + bbetaL*exp(gbar*(ies-1)/ies)*uaux^((ies-1)/(ies*(1-crra))) )^(ies/(ies-1));
|
||||||
|
R = (1-Rpers)*Rbar + Rpers*R(-1) + eeps;
|
||||||
|
ca = b*exp(gbar)-b(-1);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
initval;
|
||||||
|
R = Rbar;
|
||||||
|
m = bbetaL*exp(-gbar/ies);
|
||||||
|
q = bbetaL*exp(-gbar/ies)*Rbar;
|
||||||
|
b = bbar*(bbetaL*exp(-gbar/ies)*Rbar)^eeta;
|
||||||
|
c = 1 + Rbar*bbar*(bbetaL*exp(-gbar/ies)*Rbar)^eeta - exp(gbar)*bbar*(bbetaL*exp(-gbar/ies)*Rbar)^eeta*bbetaL*exp(-gbar/ies)*Rbar;
|
||||||
|
u = ((1-bbetaL)/(1-bbetaL*exp(gbar*(ies-1)/ies )) )^(ies/(ies-1))*(1 + Rbar*bbar*(bbetaL*exp(-gbar/ies)*Rbar)^eeta - exp(gbar)*bbar*(bbetaL*exp(-gbar/ies)*Rbar)^eeta*bbetaL*exp(-gbar/ies)*Rbar);
|
||||||
|
uaux = (1 + Rbar*bbar*(bbetaL*exp(-gbar/ies)*Rbar)^eeta - exp(gbar)*bbar*(bbetaL*exp(-gbar/ies)*Rbar)^eeta*bbetaL*exp(-gbar/ies)*Rbar)^(1-crra);
|
||||||
|
ca = (exp(gbar)-1)*bbar*(bbetaL*exp(-gbar/ies)*Rbar)^eeta;
|
||||||
|
end;
|
||||||
|
|
||||||
|
steady(solve_algo=3);
|
||||||
|
|
||||||
|
varobs q ca;
|
||||||
|
|
||||||
|
estimated_params;
|
||||||
|
ies, normal_pdf, 1.5, .2;
|
||||||
|
end;
|
||||||
|
|
||||||
|
options_.plot_priors=0;
|
|
@ -0,0 +1,14 @@
|
||||||
|
//File testing error message if no measurement error present
|
||||||
|
|
||||||
|
@#include "first_spec_common.inc"
|
||||||
|
|
||||||
|
shocks;
|
||||||
|
var eeps = 0.04^2;
|
||||||
|
var nnu = 0.03^2;
|
||||||
|
end;
|
||||||
|
|
||||||
|
stoch_simul(order=3,periods=200, irf=0, nomoments, nofunctions);
|
||||||
|
|
||||||
|
save('my_data.mat','q','ca');
|
||||||
|
|
||||||
|
estimation(datafile='my_data.mat',order=2,mode_compute=0,mh_replic=0,filter_algorithm=sis);
|
|
@ -0,0 +1,15 @@
|
||||||
|
//File testing error message if measurement error is not positive definite
|
||||||
|
|
||||||
|
@#include "first_spec_common.inc"
|
||||||
|
|
||||||
|
shocks;
|
||||||
|
var eeps = 0.04^2;
|
||||||
|
var nnu = 0.03^2;
|
||||||
|
var q = 0.01^2;
|
||||||
|
end;
|
||||||
|
|
||||||
|
stoch_simul(order=3,periods=200, irf=0);
|
||||||
|
|
||||||
|
save('my_data.mat','q','ca');
|
||||||
|
|
||||||
|
estimation(datafile='my_data.mat',order=2,mode_compute=0,mh_replic=0,filter_algorithm=sis);
|
Loading…
Reference in New Issue