From e097f7c8db304c228c4b25c902c591f826ab0246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Tue, 28 Jun 2011 14:46:43 +0200 Subject: [PATCH] Change options_.lik_init to default value if the fixed point of the Riccati equation cannot be found. --- matlab/DsgeLikelihood.m | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/matlab/DsgeLikelihood.m b/matlab/DsgeLikelihood.m index 11a98fa58..45f1b11a8 100644 --- a/matlab/DsgeLikelihood.m +++ b/matlab/DsgeLikelihood.m @@ -193,15 +193,22 @@ elseif options_.lik_init == 3 % Diffuse Kalman filter [Z,ST,R1,QT,Pstar,Pinf] = schur_statespace_transformation(mf,T,R,Q,options_.qz_criterium); elseif options_.lik_init==4 % Start from the solution of the Riccati equation. - [err, Pstar] = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(mf,np,length(mf))),H); - mexErrCheck('kalman_steady_state',err); - Pinf = []; - if kalman_algo~=2 + if kalman_algo ~= 2 kalman_algo = 1; end + if isequal(H,0) + [err,Pstar] = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(mf,np,length(mf)))); + else + [err,Pstar] = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(mf,np,length(mf))),H); + end + if err + disp(['I am not able to solve the Riccati equation so I switch to lik_init=1!']); + options_.lik_init = 1; + Pstar = lyapunov_symm(T,R*Q*R',options_.qz_criterium,options_.lyapunov_complex_threshold); + end + Pinf = []; end -if kalman_algo == 2 -end + kalman_tol = options_.kalman_tol; riccati_tol = options_.riccati_tol; mf = bayestopt_.mf1;