diff --git a/matlab/DiffuseKalmanSmoother1_Z.m b/matlab/DiffuseKalmanSmoother1_Z.m index 754dbeb8f8c4c02ac7524bcdb75cc78cae6b239c..4f843b4e8e12bfc449064df848efc1d443ee057d 100644 --- a/matlab/DiffuseKalmanSmoother1_Z.m +++ b/matlab/DiffuseKalmanSmoother1_Z.m @@ -198,7 +198,7 @@ end if nargout > 7 decomp = zeros(nk,mm,rr,smpl+nk); ZRQinv = inv(Z*QQ*Z'); - for t = d:smpl + for t = max(d,1):smpl ri_d = Z'*iF(:,:,t)*v(:,t); % calculate eta_tm1t diff --git a/matlab/DiffuseKalmanSmoother3_Z.m b/matlab/DiffuseKalmanSmoother3_Z.m index 72679dbdb7ac6358d88ce680ec061d11d11ce51f..e5c627e136701358c9db25812280a8989e1d304d 100644 --- a/matlab/DiffuseKalmanSmoother3_Z.m +++ b/matlab/DiffuseKalmanSmoother3_Z.m @@ -303,7 +303,7 @@ end if nargout > 7 decomp = zeros(nk,mm,rr,smpl+nk); ZRQinv = inv(Z*QQ*Z'); - for t = d:smpl + for t = max(d,1):smpl ri_d = zeros(mm,1); for i=pp:-1:1 if Fi(i,t) > crit diff --git a/matlab/DiffuseKalmanSmootherH1_Z.m b/matlab/DiffuseKalmanSmootherH1_Z.m index c094bb0eccc739feb63710bf31eef657056ba8a1..02ff7ce765c557f04f7b6e16d16c69bfb40a7f66 100644 --- a/matlab/DiffuseKalmanSmootherH1_Z.m +++ b/matlab/DiffuseKalmanSmootherH1_Z.m @@ -201,7 +201,7 @@ end if nargout > 7 decomp = zeros(nk,mm,rr,smpl+nk); ZRQinv = inv(Z*QQ*Z'); - for t = d:smpl + for t = max(d,1):smpl ri_d = Z'*iF(:,:,t)*v(:,t); % calculate eta_tm1t diff --git a/matlab/DiffuseKalmanSmootherH3_Z.m b/matlab/DiffuseKalmanSmootherH3_Z.m index 66ff768cf44c23bcd2bb71a74784f9862a550d8b..ec21b2348ac8c21fe4ddbadb9defba5c275c50d0 100644 --- a/matlab/DiffuseKalmanSmootherH3_Z.m +++ b/matlab/DiffuseKalmanSmootherH3_Z.m @@ -305,7 +305,7 @@ end if nargout > 7 decomp = zeros(nk,mm,rr,smpl+nk); ZRQinv = inv(Z*QQ*Z'); - for t = d:smpl + for t = max(d,1):smpl ri_d = zeros(mm,1); for i=pp:-1:1 if Fi(i,t) > crit diff --git a/matlab/DsgeSmoother.m b/matlab/DsgeSmoother.m index 4223f9e7f37ec08a93cd611e1271031d131307a0..5037c67576c7376eef5170732f43d0fca2f05e8c 100644 --- a/matlab/DsgeSmoother.m +++ b/matlab/DsgeSmoother.m @@ -175,6 +175,14 @@ function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK,T,R,P,PK,d, Z = QT(mf,:); R1 = QT'*R; + [u,s,v]=svd(Z*ST(:,1:nk),0); + k = find(abs(diag(s)) < 1e-8); + if length(k) > 0 + [junk,k1] = max(abs(v(:,k))); + dd =ones(nk,1); + dd(k1) = zeros(length(k1),1); + Pinf(1:nk,1:nk) = diag(dd); + end end % ----------------------------------------------------------------------------- % 4. Kalman smoother