Commit 80af764e authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Replaced DynareOptions by ParticleOptions and ThreadsOptions.

parent f4a1f065
function initial_distribution = auxiliary_initialization(ReducedForm,Y,start,DynareOptions) function initial_distribution = auxiliary_initialization(ReducedForm,Y,start,ParticleOptions,ThreadsOptions)
% Evaluates the likelihood of a nonlinear model with a particle filter allowing eventually resampling. % Evaluates the likelihood of a nonlinear model with a particle filter allowing eventually resampling.
% %
% INPUTS % INPUTS
...@@ -45,7 +45,7 @@ if isempty(start) ...@@ -45,7 +45,7 @@ if isempty(start)
end end
% Set flag for prunning % Set flag for prunning
%pruning = DynareOptions.particle.pruning; %pruning = ParticleOptions.pruning;
% Get steady state and mean. % Get steady state and mean.
%steadystate = ReducedForm.steadystate; %steadystate = ReducedForm.steadystate;
...@@ -58,7 +58,7 @@ if isempty(init_flag) ...@@ -58,7 +58,7 @@ if isempty(init_flag)
mf1 = ReducedForm.mf1; mf1 = ReducedForm.mf1;
number_of_observed_variables = length(mf1); number_of_observed_variables = length(mf1);
number_of_structural_innovations = length(ReducedForm.Q); number_of_structural_innovations = length(ReducedForm.Q);
number_of_particles = DynareOptions.particle.number_of_particles; number_of_particles = ParticleOptions.number_of_particles;
init_flag = 1; init_flag = 1;
end end
...@@ -102,9 +102,9 @@ StateVectors = bsxfun(@plus,StateVectorVarianceSquareRoot*randn(state_variance_r ...@@ -102,9 +102,9 @@ StateVectors = bsxfun(@plus,StateVectorVarianceSquareRoot*randn(state_variance_r
yhat = bsxfun(@minus,StateVectors,state_variables_steady_state); yhat = bsxfun(@minus,StateVectors,state_variables_steady_state);
%if pruning %if pruning
% yhat_ = bsxfun(@minus,StateVectors_,state_variables_steady_state); % yhat_ = bsxfun(@minus,StateVectors_,state_variables_steady_state);
% [tmp, tmp_] = local_state_space_iteration_2(yhat,zeros(number_of_structural_innovations,number_of_particles),ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,steadystate,DynareOptions.threads.local_state_space_iteration_2); % [tmp, tmp_] = local_state_space_iteration_2(yhat,zeros(number_of_structural_innovations,number_of_particles),ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,steadystate,ThreadsOptions.local_state_space_iteration_2);
%else %else
tmp = local_state_space_iteration_2(yhat,zeros(number_of_structural_innovations,number_of_particles),ghx,ghu,constant,ghxx,ghuu,ghxu,DynareOptions.threads.local_state_space_iteration_2); tmp = local_state_space_iteration_2(yhat,zeros(number_of_structural_innovations,number_of_particles),ghx,ghu,constant,ghxx,ghuu,ghxu,ThreadsOptions.local_state_space_iteration_2);
%end %end
PredictedObservedMean = weights*(tmp(mf1,:)'); PredictedObservedMean = weights*(tmp(mf1,:)');
PredictionError = bsxfun(@minus,Y(:,t),tmp(mf1,:)); PredictionError = bsxfun(@minus,Y(:,t),tmp(mf1,:));
...@@ -113,4 +113,4 @@ PredictedObservedVariance = bsxfun(@times,weights,dPredictedObservedMean)*dPredi ...@@ -113,4 +113,4 @@ PredictedObservedVariance = bsxfun(@times,weights,dPredictedObservedMean)*dPredi
wtilde = exp(-.5*(const_lik+log(det(PredictedObservedVariance))+sum(PredictionError.*(PredictedObservedVariance\PredictionError),1))) ; wtilde = exp(-.5*(const_lik+log(det(PredictedObservedVariance))+sum(PredictionError.*(PredictedObservedVariance\PredictionError),1))) ;
tau_tilde = weights.*wtilde ; tau_tilde = weights.*wtilde ;
tau_tilde = tau_tilde/sum(tau_tilde); tau_tilde = tau_tilde/sum(tau_tilde);
initial_distribution = resample(StateVectors',tau_tilde',DynareOptions)' ; initial_distribution = resample(StateVectors',tau_tilde',ParticleOptions)' ;
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment