- 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 argumenttime-shift
parent
e6da2849c8
commit
8c0fb55206
|
@ -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
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
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
|
||||||
% 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
|
||||||
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));
|
||||||
|
e1 = roots > 2-qz_criterium;
|
||||||
k = sum(e1); % Number of unit roots.
|
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
|
||||||
|
|
Loading…
Reference in New Issue