Fix bug in dsge_likelihood for univariate_kalman_filter

ÿÿÿ

Lines 399-418 set the measurement covariance matrix and save it to H1.
If it is diagonal, it is not recomputed again as
correlated_errors_have_been_checked is 0. In that case, lines 654-675
are not entered and univariate_kalman_filter tries to use the old H, but
it was named H1 before, leading to a crash. Changing the name of the
matrix H in lines 654-682 to H1 assures that univariate_kalman_filter
uses the correctly updated matrix of the
~correlated_errors_have_been_checked and the previously computed H1 in
the other cases.
time-shift
Johannes Pfeifer 2013-05-17 23:54:17 +02:00
parent 787b361afa
commit 115b16236b
1 changed files with 4 additions and 4 deletions

View File

@ -653,14 +653,14 @@ if (kalman_algo==2) || (kalman_algo==4)
% resetting measurement error covariance matrix when necessary %
if ~correlated_errors_have_been_checked
if isequal(H,0)
H = zeros(pp,1);
H1 = zeros(pp,1);
mmm = mm;
if analytic_derivation,
DH = zeros(pp,length(xparam1));
end
else
if all(all(abs(H-diag(diag(H)))<1e-14))% ie, the covariance matrix is diagonal...
H = diag(H);
H1 = diag(H);
mmm = mm;
clear tmp
if analytic_derivation,
@ -676,7 +676,7 @@ if (kalman_algo==2) || (kalman_algo==4)
R = blkdiag(R,eye(pp));
Pstar = blkdiag(Pstar,H);
Pinf = blckdiag(Pinf,zeros(pp));
H = zeros(pp,1);
H1 = zeros(pp,1);
mmm = mm+pp;
end
end
@ -690,7 +690,7 @@ if (kalman_algo==2) || (kalman_algo==4)
DynareOptions.kalman_tol, ...
DynareOptions.riccati_tol, ...
DynareOptions.presample, ...
T,Q,R,H,Z,mmm,pp,rr,Zflag,diffuse_periods,analytic_deriv_info{:});
T,Q,R,H1,Z,mmm,pp,rr,Zflag,diffuse_periods,analytic_deriv_info{:});
if analytic_derivation,
LIK1=LIK;
LIK=LIK1{1};