Integrates the local_state_space_iteration_3 mex into dynare's bayesian estimation eco-system

Should be merged after the mex MR !2045 and the particles MR !16
bgp-dev
NormannR 2022-08-30 14:16:14 +02:00 committed by Normann Rion
parent 755c5645a6
commit 4cdb763ea4
4 changed files with 18 additions and 5 deletions

View File

@ -108,8 +108,8 @@ if options_.discretionary_policy
end
end
% Check the perturbation order (k order perturbation based nonlinear filters are not yet implemented for k>1).
if options_.order>2 && options_.particle.pruning
% Check the perturbation order for pruning (k order perturbation based nonlinear filters are not yet implemented for k>3).
if options_.order>3 && options_.particle.pruning
error('Higher order nonlinear filters are not compatible with pruning option.')
end

View File

@ -68,8 +68,8 @@ if DynareOptions.order>1
if BayesInfo.with_trend
error('initial_estimation_checks:: particle filtering does not support trends')
end
if DynareOptions.order>2 && DynareOptions.particle.pruning==1
error('initial_estimation_checks:: the particle filter with order>2 does not support pruning')
if DynareOptions.order>3 && DynareOptions.particle.pruning==1
error('initial_estimation_checks:: the particle filter with order>3 does not support pruning')
end
if DynareOptions.particle.pruning~=DynareOptions.pruning
warning('initial_estimation_checks:: the pruning settings differ between the particle filter and the one used for IRFs/simulations. Make sure this is intended.')

View File

@ -124,10 +124,13 @@ ReducedForm.H = H;
ReducedForm.mf0 = mf0;
ReducedForm.mf1 = mf1;
if DynareOptions.k_order_solver && ~(DynareOptions.particle.pruning && DynareOptions.order==2)
if DynareOptions.order>3
ReducedForm.use_k_order_solver = true;
ReducedForm.dr = dr;
ReducedForm.udr = folded_to_unfolded_dr(dr, Model, DynareOptions);
if pruning
error('Pruning is not available for orders > 3');
end
else
ReducedForm.use_k_order_solver = false;
ReducedForm.ghx = dr.ghx(restrict_variables_idx,:);
@ -135,6 +138,14 @@ else
ReducedForm.ghxx = dr.ghxx(restrict_variables_idx,:);
ReducedForm.ghuu = dr.ghuu(restrict_variables_idx,:);
ReducedForm.ghxu = dr.ghxu(restrict_variables_idx,:);
if DynareOptions.order==3
ReducedForm.ghxxx = dr.ghxxx(restrict_variables_idx,:);
ReducedForm.ghuuu = dr.ghuuu(restrict_variables_idx,:);
ReducedForm.ghxxu = dr.ghxxu(restrict_variables_idx,:);
ReducedForm.ghxuu = dr.ghxuu(restrict_variables_idx,:);
ReducedForm.ghxss = dr.ghxss(restrict_variables_idx,:);
ReducedForm.ghuss = dr.ghuss(restrict_variables_idx,:);
end
end
% Set initial condition.

View File

@ -40,6 +40,8 @@ switch mexname
options_.threads.kronecker.sparse_hessian_times_B_kronecker_C = n;
case 'local_state_space_iteration_2'
options_.threads.local_state_space_iteration_2 = n;
case 'local_state_space_iteration_3'
options_.threads.local_state_space_iteration_3 = n;
case 'local_state_space_iteration_k'
options_.threads.local_state_space_iteration_k = n;
case 'perfect_foresight_problem'