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
parent
787b361afa
commit
115b16236b
|
@ -653,14 +653,14 @@ if (kalman_algo==2) || (kalman_algo==4)
|
||||||
% resetting measurement error covariance matrix when necessary %
|
% resetting measurement error covariance matrix when necessary %
|
||||||
if ~correlated_errors_have_been_checked
|
if ~correlated_errors_have_been_checked
|
||||||
if isequal(H,0)
|
if isequal(H,0)
|
||||||
H = zeros(pp,1);
|
H1 = zeros(pp,1);
|
||||||
mmm = mm;
|
mmm = mm;
|
||||||
if analytic_derivation,
|
if analytic_derivation,
|
||||||
DH = zeros(pp,length(xparam1));
|
DH = zeros(pp,length(xparam1));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if all(all(abs(H-diag(diag(H)))<1e-14))% ie, the covariance matrix is diagonal...
|
if all(all(abs(H-diag(diag(H)))<1e-14))% ie, the covariance matrix is diagonal...
|
||||||
H = diag(H);
|
H1 = diag(H);
|
||||||
mmm = mm;
|
mmm = mm;
|
||||||
clear tmp
|
clear tmp
|
||||||
if analytic_derivation,
|
if analytic_derivation,
|
||||||
|
@ -676,7 +676,7 @@ if (kalman_algo==2) || (kalman_algo==4)
|
||||||
R = blkdiag(R,eye(pp));
|
R = blkdiag(R,eye(pp));
|
||||||
Pstar = blkdiag(Pstar,H);
|
Pstar = blkdiag(Pstar,H);
|
||||||
Pinf = blckdiag(Pinf,zeros(pp));
|
Pinf = blckdiag(Pinf,zeros(pp));
|
||||||
H = zeros(pp,1);
|
H1 = zeros(pp,1);
|
||||||
mmm = mm+pp;
|
mmm = mm+pp;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -690,7 +690,7 @@ if (kalman_algo==2) || (kalman_algo==4)
|
||||||
DynareOptions.kalman_tol, ...
|
DynareOptions.kalman_tol, ...
|
||||||
DynareOptions.riccati_tol, ...
|
DynareOptions.riccati_tol, ...
|
||||||
DynareOptions.presample, ...
|
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,
|
if analytic_derivation,
|
||||||
LIK1=LIK;
|
LIK1=LIK;
|
||||||
LIK=LIK1{1};
|
LIK=LIK1{1};
|
||||||
|
|
Loading…
Reference in New Issue