Update calling sequence of local_state_space_iteration_k for new Fortran version
parent
2e18ca8ff5
commit
d20be2c271
|
@ -3,7 +3,7 @@ function [LIK,lik] = auxiliary_particle_filter(ReducedForm,Y,start,ParticleOptio
|
|||
% Evaluates the likelihood of a nonlinear model with the auxiliary particle filter
|
||||
% allowing eventually resampling.
|
||||
%
|
||||
% Copyright (C) 2011-2019 Dynare Team
|
||||
% Copyright (C) 2011-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare (particles module).
|
||||
%
|
||||
|
@ -42,6 +42,7 @@ number_of_particles = ParticleOptions.number_of_particles;
|
|||
|
||||
if ReducedForm.use_k_order_solver
|
||||
dr = ReducedForm.dr;
|
||||
udr = ReducedForm.udr;
|
||||
else
|
||||
% Set local state space model (first order approximation).
|
||||
ghx = ReducedForm.ghx;
|
||||
|
@ -96,7 +97,7 @@ for t=1:sample_size
|
|||
if ReducedForm.use_k_order_solver
|
||||
tmp = 0;
|
||||
for i=1:size(nodes)
|
||||
tmp = tmp + nodes_weights(i)*local_state_space_iteration_k(yhat, nodes(i,:)'*ones(1,number_of_particles), dr, Model, DynareOptions);
|
||||
tmp = tmp + nodes_weights(i)*local_state_space_iteration_k(yhat, nodes(i,:)'*ones(1,number_of_particles), dr, Model, DynareOptions, udr);
|
||||
end
|
||||
else
|
||||
tmp = 0;
|
||||
|
@ -121,7 +122,7 @@ for t=1:sample_size
|
|||
StateVectors_ = tmp_(mf0,:);
|
||||
else
|
||||
if ReducedForm.use_k_order_solver
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions);
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions, udr);
|
||||
else
|
||||
tmp = local_state_space_iteration_2(yhat, epsilon, ghx, ghu, constant, ghxx, ghuu, ghxu, ThreadsOptions.local_state_space_iteration_2);
|
||||
end
|
||||
|
@ -144,4 +145,4 @@ for t=1:sample_size
|
|||
end
|
||||
end
|
||||
|
||||
LIK = -sum(lik(start:end));
|
||||
LIK = -sum(lik(start:end));
|
||||
|
|
|
@ -22,7 +22,7 @@ function [ProposalStateVector, Weights, flag] = conditional_filter_proposal(Redu
|
|||
% - Weights
|
||||
% - flag
|
||||
|
||||
% Copyright © 2012-2020 Dynare Team
|
||||
% Copyright © 2012-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -43,6 +43,7 @@ flag = false;
|
|||
|
||||
if ReducedForm.use_k_order_solver
|
||||
dr = ReducedForm.dr;
|
||||
udr = ReducedForm.udr;
|
||||
else
|
||||
% Set local state space model (first-order approximation).
|
||||
ghx = ReducedForm.ghx;
|
||||
|
@ -79,7 +80,7 @@ epsilon = Q_lower_triangular_cholesky*nodes';
|
|||
yhat = repmat(StateVectors-state_variables_steady_state, 1, size(epsilon, 2));
|
||||
|
||||
if ReducedForm.use_k_order_solver
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions);
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions, udr);
|
||||
else
|
||||
tmp = local_state_space_iteration_2(yhat, epsilon, ghx, ghu, constant, ghxx, ghuu, ghxu, ThreadsOptions.local_state_space_iteration_2);
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ function [PredictedStateMean, PredictedStateVarianceSquareRoot, StateVectorMean,
|
|||
% NOTES
|
||||
% The vector "lik" is used to evaluate the jacobian of the likelihood.
|
||||
|
||||
% Copyright (C) 2009-2017 Dynare Team
|
||||
% Copyright (C) 2009-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -41,6 +41,7 @@ function [PredictedStateMean, PredictedStateVarianceSquareRoot, StateVectorMean,
|
|||
|
||||
if ReducedForm.use_k_order_solver
|
||||
dr = ReducedForm.dr;
|
||||
udr = ReducedForm.udr;
|
||||
else
|
||||
% Set local state space model (first-order approximation).
|
||||
ghx = ReducedForm.ghx;
|
||||
|
@ -81,7 +82,7 @@ StateVectors = sigma_points(1:number_of_state_variables,:);
|
|||
epsilon = sigma_points(number_of_state_variables+1:number_of_state_variables+number_of_structural_innovations,:);
|
||||
yhat = bsxfun(@minus, StateVectors, state_variables_steady_state);
|
||||
if ReducedForm.use_k_order_solver
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions);
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions, udr);
|
||||
else
|
||||
tmp = local_state_space_iteration_2(yhat, epsilon, ghx, ghu, constant, ghxx, ghuu, ghxu, ThreadsOptions.local_state_space_iteration_2);
|
||||
end
|
||||
|
@ -116,4 +117,4 @@ else
|
|||
StateVectorVariance = PredictedStateVariance - KalmanFilterGain*PredictedObservedVariance*KalmanFilterGain';
|
||||
StateVectorVariance = .5*(StateVectorVariance+StateVectorVariance');
|
||||
StateVectorVarianceSquareRoot = reduced_rank_cholesky(StateVectorVariance)';
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ function [StateMuPrior,StateSqrtPPrior,StateWeightsPrior,StateMuPost,StateSqrtPP
|
|||
% NOTES
|
||||
% The vector "lik" is used to evaluate the jacobian of the likelihood.
|
||||
|
||||
% Copyright (C) 2009-2019 Dynare Team
|
||||
% Copyright (C) 2009-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -43,6 +43,7 @@ function [StateMuPrior,StateSqrtPPrior,StateWeightsPrior,StateMuPost,StateSqrtPP
|
|||
|
||||
if ReducedForm.use_k_order_solver
|
||||
dr = ReducedForm.dr;
|
||||
udr = ReducedForm.udr;
|
||||
else
|
||||
% Set local state space model (first-order approximation).
|
||||
ghx = ReducedForm.ghx;
|
||||
|
@ -77,7 +78,7 @@ epsilon = bsxfun(@plus, StructuralShocksSqrtP*nodes3(:,number_of_state_variables
|
|||
StateVectors = bsxfun(@plus, StateSqrtP*nodes3(:,1:number_of_state_variables)', StateMu);
|
||||
yhat = bsxfun(@minus, StateVectors, state_variables_steady_state);
|
||||
if ReducedForm.use_k_order_solver
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions);
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions, udr);
|
||||
else
|
||||
tmp = local_state_space_iteration_2(yhat, epsilon, ghx, ghu, constant, ghxx, ghuu, ghxu, ThreadsOptions.local_state_space_iteration_2);
|
||||
end
|
||||
|
@ -123,4 +124,4 @@ StateSqrtPPrior = reduced_rank_cholesky(PredictedStateVariance)';
|
|||
StateWeightsPrior = StateWeights*StructuralShocksWeights;
|
||||
StateMuPost = StateVectorMean;
|
||||
StateSqrtPPost = StateVectorVarianceSquareRoot;
|
||||
StateWeightsPost = StateWeightsPrior*ObservationShocksWeights*data_lik_GM_g;
|
||||
StateWeightsPost = StateWeightsPrior*ObservationShocksWeights*data_lik_GM_g;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
function measure = measurement_equations(StateVectors,ReducedForm,ThreadsOptions, DynareOptions, Model)
|
||||
|
||||
% Copyright (C) 2013-2019 Dynare Team
|
||||
% Copyright (C) 2013-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -20,6 +20,7 @@ function measure = measurement_equations(StateVectors,ReducedForm,ThreadsOptions
|
|||
mf1 = ReducedForm.mf1;
|
||||
if ReducedForm.use_k_order_solver
|
||||
dr = ReducedForm.dr;
|
||||
udr = ReducedForm.udr;
|
||||
else
|
||||
ghx = ReducedForm.ghx(mf1,:);
|
||||
ghu = ReducedForm.ghu(mf1,:);
|
||||
|
@ -32,8 +33,8 @@ state_variables_steady_state = ReducedForm.state_variables_steady_state;
|
|||
number_of_structural_innovations = length(ReducedForm.Q);
|
||||
yhat = bsxfun(@minus, StateVectors, state_variables_steady_state);
|
||||
if ReducedForm.use_k_order_solver
|
||||
tmp = local_state_space_iteration_k(yhat, zeros(number_of_structural_innovations, size(yhat,2)), dr, Model, DynareOptions);
|
||||
tmp = local_state_space_iteration_k(yhat, zeros(number_of_structural_innovations, size(yhat,2)), dr, Model, DynareOptions, udr);
|
||||
measure = tmp(mf1,:);
|
||||
else
|
||||
measure = local_state_space_iteration_2(yhat, zeros(number_of_structural_innovations, size(yhat,2)), ghx, ghu, constant, ghxx, ghuu, ghxu, ThreadsOptions.local_state_space_iteration_2);
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ function [LIK,lik] = nonlinear_kalman_filter(ReducedForm, Y, start, ParticleOpti
|
|||
% NOTES
|
||||
% The vector "lik" is used to evaluate the jacobian of the likelihood.
|
||||
|
||||
% Copyright (C) 2009-2019 Dynare Team
|
||||
% Copyright (C) 2009-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -56,6 +56,7 @@ end
|
|||
|
||||
if ReducedForm.use_k_order_solver
|
||||
dr = ReducedForm.dr;
|
||||
udr = ReducedForm.udr;
|
||||
else
|
||||
% Set local state space model (first-order approximation).
|
||||
ghx = ReducedForm.ghx;
|
||||
|
@ -116,7 +117,7 @@ for t=1:sample_size
|
|||
epsilon = sigma_points(number_of_state_variables+1:number_of_state_variables+number_of_structural_innovations,:);
|
||||
yhat = bsxfun(@minus,StateVectors,state_variables_steady_state);
|
||||
if ReducedForm.use_k_order_solver
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions);
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions, udr);
|
||||
else
|
||||
tmp = local_state_space_iteration_2(yhat, epsilon, ghx, ghu, constant, ghxx, ghuu, ghxu, ThreadsOptions.local_state_space_iteration_2);
|
||||
end
|
||||
|
@ -161,4 +162,4 @@ for t=1:sample_size
|
|||
lik(t) = log( sum(probability2(Y(:,t),H_lower_triangular_cholesky,tmp(mf1,:)).*weights,1) ) ;
|
||||
end
|
||||
|
||||
LIK = -sum(lik(start:end));
|
||||
LIK = -sum(lik(start:end));
|
||||
|
|
|
@ -21,7 +21,7 @@ function [pmean, pmode, pmedian, pstdev, p025, p975, covariance] = online_auxili
|
|||
% - p975 [double] n×1 vector, 97.5 percent of the particles are below p975(i) for i=1,…,n.
|
||||
% - covariance [double] n×n matrix, covariance of the particles at the end of the sample.
|
||||
|
||||
% Copyright © 2013-2021 Dynare Team
|
||||
% Copyright © 2013-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -125,6 +125,7 @@ for t=1:sample_size
|
|||
% Set local state space model (second-order approximation).
|
||||
if ReducedForm.use_k_order_solver
|
||||
dr = ReducedForm.dr;
|
||||
udr = ReducedForm.udr;
|
||||
else
|
||||
constant = ReducedForm.constant;
|
||||
% Set local state space model (first-order approximation).
|
||||
|
@ -138,7 +139,7 @@ for t=1:sample_size
|
|||
% particle likelihood contribution
|
||||
yhat = bsxfun(@minus, StateVectors(:,i), state_variables_steady_state);
|
||||
if ReducedForm.use_k_order_solver
|
||||
tmp = local_state_space_iteration_k(yhat, zeros(number_of_structural_innovations, 1), dr, Model, DynareOptions);
|
||||
tmp = local_state_space_iteration_k(yhat, zeros(number_of_structural_innovations, 1), dr, Model, DynareOptions, udr);
|
||||
else
|
||||
if pruning
|
||||
yhat_ = bsxfun(@minus,StateVectors_(:,i),state_variables_steady_state);
|
||||
|
@ -181,6 +182,7 @@ for t=1:sample_size
|
|||
% Set local state space model (second order approximation).
|
||||
if ReducedForm.use_k_order_solver
|
||||
dr = ReducedForm.dr;
|
||||
udr = ReducedForm.udr;
|
||||
else
|
||||
constant = ReducedForm.constant;
|
||||
% Set local state space model (first-order approximation).
|
||||
|
@ -196,7 +198,7 @@ for t=1:sample_size
|
|||
% compute particles likelihood contribution
|
||||
yhat = bsxfun(@minus,StateVectors(:,i), state_variables_steady_state);
|
||||
if ReducedForm.use_k_order_solver
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions);
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions, udr);
|
||||
else
|
||||
if pruning
|
||||
yhat_ = bsxfun(@minus,StateVectors_(:,i), state_variables_steady_state);
|
||||
|
|
|
@ -2,7 +2,7 @@ function [LIK,lik] = sequential_importance_particle_filter(ReducedForm,Y,start,P
|
|||
|
||||
% Evaluates the likelihood of a nonlinear model with a particle filter (optionally with resampling).
|
||||
|
||||
% Copyright (C) 2011-2015 Dynare Team
|
||||
% Copyright (C) 2011-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare (particles module).
|
||||
%
|
||||
|
@ -51,6 +51,7 @@ end
|
|||
|
||||
if ReducedForm.use_k_order_solver
|
||||
dr = ReducedForm.dr;
|
||||
udr = ReducedForm.udr;
|
||||
else
|
||||
% Set local state space model (first order approximation).
|
||||
ghx = ReducedForm.ghx;
|
||||
|
@ -106,7 +107,7 @@ for t=1:sample_size
|
|||
[tmp, tmp_] = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,steadystate,ThreadsOptions.local_state_space_iteration_2);
|
||||
else
|
||||
if ReducedForm.use_k_order_solver
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions);
|
||||
tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions, udr);
|
||||
else
|
||||
tmp = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,ThreadsOptions.local_state_space_iteration_2);
|
||||
end
|
||||
|
@ -143,4 +144,4 @@ for t=1:sample_size
|
|||
end
|
||||
end
|
||||
|
||||
LIK = -sum(lik(start:end));
|
||||
LIK = -sum(lik(start:end));
|
||||
|
|
|
@ -20,7 +20,7 @@ function [info, Model, DynareOptions, DynareResults, ReducedForm] = ...
|
|||
% - DynareResults [struct] Dynare results (oo_).
|
||||
% - ReducedForm [struct] Reduced form model.
|
||||
|
||||
% Copyright (C) 2013-2019 Dynare Team
|
||||
% Copyright (C) 2013-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -164,6 +164,7 @@ if nargout>4
|
|||
elseif DynareOptions.order>=3
|
||||
ReducedForm.use_k_order_solver = true;
|
||||
ReducedForm.dr = dr;
|
||||
ReducedForm.udr = folded_to_unfolded_dr(dr, Model, DynareOptions);
|
||||
else
|
||||
n_states=size(dr.ghx,2);
|
||||
n_shocks=size(dr.ghu,2);
|
||||
|
@ -210,4 +211,4 @@ if setinitialcondition
|
|||
end
|
||||
ReducedForm.StateVectorMean = StateVectorMean;
|
||||
ReducedForm.StateVectorVariance = StateVectorVariance;
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue