Skip to content
Snippets Groups Projects
Commit 74d7c8a7 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Merge branch 'pf_init' into 'master'

Fix initialization of state variances

See merge request !1762
parents 5fd2a064 dab5d380
No related branches found
No related tags found
1 merge request!1762Fix initialization of state variances
Pipeline #4371 passed
...@@ -135,14 +135,16 @@ end ...@@ -135,14 +135,16 @@ end
switch DynareOptions.particle.initialization switch DynareOptions.particle.initialization
case 1% Initial state vector covariance is the ergodic variance associated to the first order Taylor-approximation of the model. case 1% Initial state vector covariance is the ergodic variance associated to the first order Taylor-approximation of the model.
StateVectorMean = ReducedForm.constant(mf0); StateVectorMean = ReducedForm.constant(mf0);
StateVectorVariance = lyapunov_symm(dr.ghx(mf0,:), dr.ghu(mf0,:)*Q*dr.ghu(mf0,:)', DynareOptions.lyapunov_fixed_point_tol, ... [A,B] = kalman_transition_matrix(dr,dr.restrict_var_list,dr.restrict_columns,Model.exo_nbr);
StateVectorVariance = lyapunov_symm(A, B*Q*B', DynareOptions.lyapunov_fixed_point_tol, ...
DynareOptions.qz_criterium, DynareOptions.lyapunov_complex_threshold, [], DynareOptions.debug); DynareOptions.qz_criterium, DynareOptions.lyapunov_complex_threshold, [], DynareOptions.debug);
StateVectorVariance = StateVectorVariance(mf0,mf0);
case 2% Initial state vector covariance is a monte-carlo based estimate of the ergodic variance (consistent with a k-order Taylor-approximation of the model). case 2% Initial state vector covariance is a monte-carlo based estimate of the ergodic variance (consistent with a k-order Taylor-approximation of the model).
StateVectorMean = ReducedForm.constant(mf0); StateVectorMean = ReducedForm.constant(mf0);
old_DynareOptionsperiods = DynareOptions.periods; old_DynareOptionsperiods = DynareOptions.periods;
DynareOptions.periods = 5000; DynareOptions.periods = 5000;
y_ = simult(DynareResults.steady_state, dr,Model,DynareOptions,DynareResults); y_ = simult(DynareResults.steady_state, dr,Model,DynareOptions,DynareResults);
y_ = y_(state_variables_idx,2001:5000); y_ = y_(dr.order_var(state_variables_idx),2001:5000); %state_variables_idx is in dr-order while simult_ is in declaration order
StateVectorVariance = cov(y_'); StateVectorVariance = cov(y_');
DynareOptions.periods = old_DynareOptionsperiods; DynareOptions.periods = old_DynareOptionsperiods;
clear('old_DynareOptionsperiods','y_'); clear('old_DynareOptionsperiods','y_');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment