Skip to content
This repository has been archived by the owner. It is now read-only.

Three bugfixes for missing_DiffuseKalmanSmootherH1_Z.m that led to wrong results #1324

Merged
merged 9 commits into from Nov 13, 2016

Conversation

Projects
None yet
2 participants
@JohannesPfeifer
Copy link
Contributor

commented Oct 28, 2016

  1. In case of missing observations ('if isempty(di)'), a(:,t) was not propagated forward to update a(:,t+1)
  2. In the rank-deficient Finf case, Kstar was defined as T^(-1)*K^{(0)}, while in the full rank it was defined as Kstar=K^(0) This leads to wrong results when switches between the two clauses occurr. Moreover, the later backwards pass relied on Kstar=K^(0), leading to wrong results when the rank-deficient Finf case was triggered earlier.
  3. In the rank-deficient Finf case, the backward pass did not use the proper formulas, but rather the ones for the non-singular case

The implementation now consistently follows the one in kalman_filter_d.m

if ~all(abs(Fstar(:,:,t))<kalman_tol)
% The univariate diffuse kalman filter should be used.
alphahat = Inf;
return
else
else %rank 0
a(:,t+1) = T*a(:,t);
Pstar(:,:,t+1) = T*Pstar(:,:,t)*transpose(T)+QQ;
Pinf(:,:,t+1) = T*Pinf(:,:,t)*transpose(T);
end
else
iFstar = inv(Fstar(:,:,t));

This comment has been minimized.

Copy link
@JohannesPfeifer

JohannesPfeifer Oct 28, 2016

Author Contributor

There seems to be a third bug here. iFstar only stores the matrix for every t, but the next line uses it with a t index. I will fix this when I am back at my computer.

@JohannesPfeifer JohannesPfeifer changed the title Two bugfixes for missing_DiffuseKalmanSmootherH1_Z.m that led to wrong results Three bugfixes for missing_DiffuseKalmanSmootherH1_Z.m that led to wrong results Oct 31, 2016

@JohannesPfeifer JohannesPfeifer force-pushed the JohannesPfeifer:kalman branch 3 times, most recently from 36ea82d to 76bea16 Oct 31, 2016

JohannesPfeifer added some commits Oct 28, 2016

2 bugfixes for missing_DiffuseKalmanSmootherH1_Z.m that led to wrong …
…results

1. In case of missing observations, a_t was not propagated forward to updated a_t+1
2. In the rank-deficient Finf case, Kstar was defined as T^(-1)*K^(0), while in the full rank it was defined as Kstar=K^(0), leading to wrong results when switches between the two clauses occurred. Moreover, the later backwards pass relied on Kstar=K^(0), leading to wrong results when the rank-deficient Finf case was triggered. The implementation now consistently follows the one in kalman_filter_d.m
missing_DiffuseKalmanSmootherH1_Z.m: fix crash when Pinf is singular …
…for more than 1 period

iFstar was accessed as three-dimensional array with t along third dimension, but it is only two-dimensional
Diffuse Kalman filter: add comment for better comparison to Koopman/D…
…urbin (2003) as there is a typo in their paper
missing_DiffuseKalmanSmootherH1_Z.m: introduce proper case distinctio…
…n in diffuse backward pass if Finf is singular
Document missing_DiffuseKalmanSmootherH3_Z.m
Also properly initializes Kinf

@JohannesPfeifer JohannesPfeifer force-pushed the JohannesPfeifer:kalman branch from 76bea16 to 3ebc982 Nov 4, 2016

@MichelJuillard MichelJuillard merged commit 31d2c7e into DynareTeam:master Nov 13, 2016

@JohannesPfeifer JohannesPfeifer deleted the JohannesPfeifer:kalman branch Nov 13, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.