Merge pull request #1428 from JohannesPfeifer/patch-1

Test the rank of Pinf in univariate smoother for the subset of observables
time-shift
Houtan Bastani 2017-04-01 09:57:32 +02:00 committed by GitHub
commit f18c16653e
2 changed files with 24 additions and 4 deletions

View File

@ -255,7 +255,9 @@ if kalman_algo == 2 || kalman_algo == 4
[Pstar,Pinf] = compute_Pinf_Pstar(mf,ST,R1,Q,options_.qz_criterium);
else
Pstar = blkdiag(Pstar,H);
Pinf = blkdiag(Pinf,zeros(vobs));
if ~isempty(Pinf)
Pinf = blkdiag(Pinf,zeros(vobs));
end
end
%now reset H to 0
H = zeros(vobs,vobs);

View File

@ -122,7 +122,11 @@ end
t = 0;
icc=0;
newRank = rank(Pinf(:,:,1),diffuse_kalman_tol);
if ~isempty(Pinf(:,:,1))
newRank = rank(Z*Pinf(:,:,1)*Z',diffuse_kalman_tol);
else
newRank = rank(Pinf(:,:,1),diffuse_kalman_tol);
end
while newRank && t < smpl
t = t+1;
a(:,t) = a1(:,t);
@ -156,7 +160,11 @@ while newRank && t < smpl
end
end
if newRank
oldRank = rank(Pinf(:,:,t),diffuse_kalman_tol);
if ~isempty(Pinf(:,:,t))
oldRank = rank(Z*Pinf(:,:,t)*Z',diffuse_kalman_tol);
else
oldRank = rank(Pinf(:,:,t),diffuse_kalman_tol);
end
else
oldRank = 0;
end
@ -168,7 +176,11 @@ while newRank && t < smpl
Pstar(:,:,t+1) = T*Pstar(:,:,t)*T'+ QQ;
Pinf(:,:,t+1) = T*Pinf(:,:,t)*T';
if newRank
newRank = rank(Pinf(:,:,t+1),diffuse_kalman_tol);
if ~isempty(Pinf(:,:,t+1))
newRank = rank(Z*Pinf(:,:,t+1)*Z',diffuse_kalman_tol);
else
newRank = rank(Pinf(:,:,t+1),diffuse_kalman_tol);
end
end
if oldRank ~= newRank
disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!')
@ -367,3 +379,9 @@ if decomp_flag
end
epsilonhat = Y - Z*alphahat;
if (d==smpl)
warning(['missing_DiffuseKalmanSmootherH3_Z:: There isn''t enough information to estimate the initial conditions of the nonstationary variables']);
return
end