Commit 8c0fb552 authored by Michel Juillard's avatar Michel Juillard

- added a test an a penalty in estimation (DsgeLikelihood.m) if, in a...

- added a test an a penalty in estimation (DsgeLikelihood.m) if, in a stationary model (lik_init==1), a particular parameter set generates unit roots.
- modified lyapunov_symm to return absolute value of unit roots in a third argument
parent e6da2849
...@@ -170,7 +170,15 @@ if options_.lik_init == 1 % Kalman filter ...@@ -170,7 +170,15 @@ if options_.lik_init == 1 % Kalman filter
if kalman_algo ~= 2 if kalman_algo ~= 2
kalman_algo = 1; kalman_algo = 1;
end end
Pstar = lyapunov_symm(T,R*Q*R',options_.qz_criterium,options_.lyapunov_complex_threshold); [Pstar,junk,unit_roots] = lyapunov_symm(T,R*Q*R',options_.qz_criterium,...
options_.lyapunov_complex_threshold);
if ~isempty(unit_roots)
% if unit roots the penalty equals the sum of distance to 2-qz_criterium
fval = bayestopt_.penalty + sum(unit_roots-2+ ...
options_.qz_criterium);
cost_flag = 0;
return
end
Pinf = []; Pinf = [];
elseif options_.lik_init == 2 % Old Diffuse Kalman filter elseif options_.lik_init == 2 % Old Diffuse Kalman filter
if kalman_algo ~= 2 if kalman_algo ~= 2
......
function [x,u] = lyapunov_symm(a,b,qz_criterium,lyapunov_complex_threshold,method) function [x,u,unit_roots] = lyapunov_symm(a,b,qz_criterium,lyapunov_complex_threshold,method)
% Solves the Lyapunov equation x-a*x*a' = b, for b and x symmetric matrices. % Solves the Lyapunov equation x-a*x*a' = b, for b and x symmetric matrices.
% If a has some unit roots, the function computes only the solution of the stable subsystem. % If a has some unit roots, the function computes only the solution of the stable subsystem.
% %
...@@ -15,6 +15,7 @@ function [x,u] = lyapunov_symm(a,b,qz_criterium,lyapunov_complex_threshold,metho ...@@ -15,6 +15,7 @@ function [x,u] = lyapunov_symm(a,b,qz_criterium,lyapunov_complex_threshold,metho
% OUTPUTS % OUTPUTS
% x: [double] m*m solution matrix of the lyapunov equation, where m is the dimension of the stable subsystem. % x: [double] m*m solution matrix of the lyapunov equation, where m is the dimension of the stable subsystem.
% u: [double] Schur vectors associated with unit roots % u: [double] Schur vectors associated with unit roots
% unit_roots [double] vector containing roots too close to 1
% %
% ALGORITHM % ALGORITHM
% Uses reordered Schur decomposition % Uses reordered Schur decomposition
...@@ -57,10 +58,13 @@ if size(a,1) == 1 ...@@ -57,10 +58,13 @@ if size(a,1) == 1
return return
end end
unit_roots = [];
if method<2 if method<2
[U,T] = schur(a); [U,T] = schur(a);
e1 = abs(ordeig(T)) > 2-qz_criterium; roots = abs(ordeig(T));
k = sum(e1); % Number of unit roots. e1 = roots > 2-qz_criterium;
k = sum(e1); % Number of unit roots.
unit_roots = roots(1:k);
n = length(e1)-k; % Number of stationary variables. n = length(e1)-k; % Number of stationary variables.
if k > 0 if k > 0
% Selects stable roots % Selects stable roots
......
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