Fix bug when unit root models provide NaN's or Inf's in g_omega
parent
4c4cfd441c
commit
b33da9a40d
|
@ -202,11 +202,15 @@ else% ==> Theoretical HP filter.
|
||||||
IA = eye(size(A,1));
|
IA = eye(size(A,1));
|
||||||
IE = eye(M_.exo_nbr);
|
IE = eye(M_.exo_nbr);
|
||||||
for ig = 1:ngrid
|
for ig = 1:ngrid
|
||||||
f_omega =(1/(2*pi))*( [inv(IA-A*tneg(ig))*ghu1;IE]...
|
if hp1(ig)==0,
|
||||||
*M_.Sigma_e*[ghu1'*inv(IA-A'*tpos(ig)) ...
|
f_hp = zeros(length(ivar),length(ivar));
|
||||||
IE]); % state variables
|
else
|
||||||
g_omega = [aa*tneg(ig) bb]*f_omega*[aa'*tpos(ig); bb']; % selected variables
|
f_omega =(1/(2*pi))*( [inv(IA-A*tneg(ig))*ghu1;IE]...
|
||||||
f_hp = hp1(ig)^2*g_omega; % spectral density of selected filtered series
|
*M_.Sigma_e*[ghu1'*inv(IA-A'*tpos(ig)) ...
|
||||||
|
IE]); % state variables
|
||||||
|
g_omega = [aa*tneg(ig) bb]*f_omega*[aa'*tpos(ig); bb']; % selected variables
|
||||||
|
f_hp = hp1(ig)^2*g_omega; % spectral density of selected filtered series
|
||||||
|
end
|
||||||
mathp_col = [mathp_col ; (f_hp(:))']; % store as matrix row
|
mathp_col = [mathp_col ; (f_hp(:))']; % store as matrix row
|
||||||
% for ifft
|
% for ifft
|
||||||
end;
|
end;
|
||||||
|
@ -233,11 +237,15 @@ else% ==> Theoretical HP filter.
|
||||||
IA = eye(size(A,1));
|
IA = eye(size(A,1));
|
||||||
IE = eye(M_.exo_nbr);
|
IE = eye(M_.exo_nbr);
|
||||||
for ig = 1:ngrid
|
for ig = 1:ngrid
|
||||||
f_omega =(1/(2*pi))*( [inv(IA-A*tneg(ig))*b1;IE]...
|
if hp1(ig)==0,
|
||||||
*SS*[b1'*inv(IA-A'*tpos(ig)) ...
|
f_hp = zeros(length(ivar),length(ivar));
|
||||||
IE]); % state variables
|
else
|
||||||
g_omega = [aa*tneg(ig) b2]*f_omega*[aa'*tpos(ig); b2']; % selected variables
|
f_omega =(1/(2*pi))*( [inv(IA-A*tneg(ig))*b1;IE]...
|
||||||
f_hp = hp1(ig)^2*g_omega; % spectral density of selected filtered series
|
*SS*[b1'*inv(IA-A'*tpos(ig)) ...
|
||||||
|
IE]); % state variables
|
||||||
|
g_omega = [aa*tneg(ig) b2]*f_omega*[aa'*tpos(ig); b2']; % selected variables
|
||||||
|
f_hp = hp1(ig)^2*g_omega; % spectral density of selected filtered series
|
||||||
|
end
|
||||||
mathp_col = [mathp_col ; (f_hp(:))']; % store as matrix row
|
mathp_col = [mathp_col ; (f_hp(:))']; % store as matrix row
|
||||||
% for ifft
|
% for ifft
|
||||||
end;
|
end;
|
||||||
|
@ -247,13 +255,17 @@ else% ==> Theoretical HP filter.
|
||||||
mathp_col = [];
|
mathp_col = [];
|
||||||
SSi = cs(:,i)*cs(:,i)';
|
SSi = cs(:,i)*cs(:,i)';
|
||||||
for ig = 1:ngrid
|
for ig = 1:ngrid
|
||||||
f_omega =(1/(2*pi))*( [inv(IA-A*tneg(ig))*b1;IE]...
|
if hp1(ig)==0,
|
||||||
*SSi*[b1'*inv(IA-A'*tpos(ig)) ...
|
f_hp = zeros(length(ivar),length(ivar));
|
||||||
IE]); % state variables
|
else
|
||||||
g_omega = [aa*tneg(ig) b2]*f_omega*[aa'*tpos(ig); b2']; % selected variables
|
f_omega =(1/(2*pi))*( [inv(IA-A*tneg(ig))*b1;IE]...
|
||||||
f_hp = hp1(ig)^2*g_omega; % spectral density of selected filtered series
|
*SSi*[b1'*inv(IA-A'*tpos(ig)) ...
|
||||||
|
IE]); % state variables
|
||||||
|
g_omega = [aa*tneg(ig) b2]*f_omega*[aa'*tpos(ig); b2']; % selected variables
|
||||||
|
f_hp = hp1(ig)^2*g_omega; % spectral density of selected filtered series
|
||||||
|
end
|
||||||
mathp_col = [mathp_col ; (f_hp(:))']; % store as matrix row
|
mathp_col = [mathp_col ; (f_hp(:))']; % store as matrix row
|
||||||
% for ifft
|
% for ifft
|
||||||
end;
|
end;
|
||||||
imathp_col = real(ifft(mathp_col))*(2*pi);
|
imathp_col = real(ifft(mathp_col))*(2*pi);
|
||||||
Gamma_y{nar+2}(:,i) = abs(diag(reshape(imathp_col(1,:),nvar,nvar)))./vv;
|
Gamma_y{nar+2}(:,i) = abs(diag(reshape(imathp_col(1,:),nvar,nvar)))./vv;
|
||||||
|
|
Loading…
Reference in New Issue