Allow k order approximation in SIP filter.
parent
bc1c173988
commit
b8180f3328
|
@ -1,4 +1,4 @@
|
||||||
function [LIK,lik] = sequential_importance_particle_filter(ReducedForm,Y,start,ParticleOptions,ThreadsOptions)
|
function [LIK,lik] = sequential_importance_particle_filter(ReducedForm,Y,start,ParticleOptions,ThreadsOptions, DynareOptions, Model)
|
||||||
|
|
||||||
% Evaluates the likelihood of a nonlinear model with a particle filter (optionally with resampling).
|
% Evaluates the likelihood of a nonlinear model with a particle filter (optionally with resampling).
|
||||||
|
|
||||||
|
@ -49,14 +49,18 @@ if isempty(init_flag)
|
||||||
init_flag = 1;
|
init_flag = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
% Set local state space model (first order approximation).
|
if ReducedForm.use_k_order_solver
|
||||||
ghx = ReducedForm.ghx;
|
dr = ReducedForm.dr;
|
||||||
ghu = ReducedForm.ghu;
|
else
|
||||||
|
% Set local state space model (first order approximation).
|
||||||
|
ghx = ReducedForm.ghx;
|
||||||
|
ghu = ReducedForm.ghu;
|
||||||
|
|
||||||
% Set local state space model (second order approximation).
|
% Set local state space model (second order approximation).
|
||||||
ghxx = ReducedForm.ghxx;
|
ghxx = ReducedForm.ghxx;
|
||||||
ghuu = ReducedForm.ghuu;
|
ghuu = ReducedForm.ghuu;
|
||||||
ghxu = ReducedForm.ghxu;
|
ghxu = ReducedForm.ghxu;
|
||||||
|
end
|
||||||
|
|
||||||
% Get covariance matrices.
|
% Get covariance matrices.
|
||||||
Q = ReducedForm.Q; % Covariance matrix of the structural innovations.
|
Q = ReducedForm.Q; % Covariance matrix of the structural innovations.
|
||||||
|
@ -101,7 +105,11 @@ for t=1:sample_size
|
||||||
yhat_ = bsxfun(@minus,StateVectors_,state_variables_steady_state);
|
yhat_ = bsxfun(@minus,StateVectors_,state_variables_steady_state);
|
||||||
[tmp, tmp_] = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,steadystate,ThreadsOptions.local_state_space_iteration_2);
|
[tmp, tmp_] = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,steadystate,ThreadsOptions.local_state_space_iteration_2);
|
||||||
else
|
else
|
||||||
tmp = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,ThreadsOptions.local_state_space_iteration_2);
|
if ReducedForm.use_k_order_solver
|
||||||
|
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions);
|
||||||
|
else
|
||||||
|
tmp = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,ThreadsOptions.local_state_space_iteration_2);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
%PredictedObservedMean = tmp(mf1,:)*transpose(weights);
|
%PredictedObservedMean = tmp(mf1,:)*transpose(weights);
|
||||||
PredictionError = bsxfun(@minus,Y(:,t),tmp(mf1,:));
|
PredictionError = bsxfun(@minus,Y(:,t),tmp(mf1,:));
|
||||||
|
|
Loading…
Reference in New Issue