calling always multivariate Kalman filter first, even if univariate
diffuse Kalman filter was used beforetime-shift
parent
cfb5114d41
commit
636cd1bae6
|
@ -359,6 +359,7 @@ end
|
||||||
|
|
||||||
diffuse_periods = 0;
|
diffuse_periods = 0;
|
||||||
correlated_errors_have_been_checked = 0;
|
correlated_errors_have_been_checked = 0;
|
||||||
|
singular_diffuse_filter = 0;
|
||||||
switch DynareOptions.lik_init
|
switch DynareOptions.lik_init
|
||||||
case 1% Standard initialization with the steady state of the state equation.
|
case 1% Standard initialization with the steady state of the state equation.
|
||||||
if kalman_algo~=2
|
if kalman_algo~=2
|
||||||
|
@ -407,17 +408,17 @@ switch DynareOptions.lik_init
|
||||||
diffuse_periods = length(tmp);
|
diffuse_periods = length(tmp);
|
||||||
if isinf(dLIK)
|
if isinf(dLIK)
|
||||||
% Go to univariate diffuse filter if singularity problem.
|
% Go to univariate diffuse filter if singularity problem.
|
||||||
kalman_algo = 4;
|
singular_diffuse_filter = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (kalman_algo==4)
|
if singular_diffuse_filter || (kalman_algo==4)
|
||||||
% Univariate Diffuse Kalman Filter
|
% Univariate Diffuse Kalman Filter
|
||||||
if isequal(H,0)
|
if isequal(H,0)
|
||||||
H = zeros(nobs,1);
|
H1 = zeros(nobs,1);
|
||||||
mmm = mm;
|
mmm = mm;
|
||||||
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;
|
||||||
else
|
else
|
||||||
Z = [Z, eye(pp)];
|
Z = [Z, eye(pp)];
|
||||||
|
@ -426,7 +427,7 @@ switch DynareOptions.lik_init
|
||||||
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(nobs,1);
|
H1 = zeros(nobs,1);
|
||||||
mmm = mm+pp;
|
mmm = mm+pp;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -439,7 +440,7 @@ switch DynareOptions.lik_init
|
||||||
Y, 1, size(Y,2), ...
|
Y, 1, size(Y,2), ...
|
||||||
zeros(mmm,1), Pinf, Pstar, ...
|
zeros(mmm,1), Pinf, Pstar, ...
|
||||||
kalman_tol, riccati_tol, DynareOptions.presample, ...
|
kalman_tol, riccati_tol, DynareOptions.presample, ...
|
||||||
T,R,Q,H,Z,mmm,pp,rr);
|
T,R,Q,H1,Z,mmm,pp,rr);
|
||||||
diffuse_periods = length(tmp);
|
diffuse_periods = length(tmp);
|
||||||
end
|
end
|
||||||
case 4% Start from the solution of the Riccati equation.
|
case 4% Start from the solution of the Riccati equation.
|
||||||
|
|
|
@ -255,6 +255,7 @@ end
|
||||||
|
|
||||||
diffuse_periods = 0;
|
diffuse_periods = 0;
|
||||||
correlated_errors_have_been_checked = 0;
|
correlated_errors_have_been_checked = 0;
|
||||||
|
singular_diffuse_filter = 0;
|
||||||
switch DynareOptions.lik_init
|
switch DynareOptions.lik_init
|
||||||
case 1% Standard initialization with the steady state of the state equation.
|
case 1% Standard initialization with the steady state of the state equation.
|
||||||
if kalman_algo~=2
|
if kalman_algo~=2
|
||||||
|
@ -303,18 +304,17 @@ switch DynareOptions.lik_init
|
||||||
diffuse_periods = length(dlik);
|
diffuse_periods = length(dlik);
|
||||||
if isinf(dLIK)
|
if isinf(dLIK)
|
||||||
% Go to univariate diffuse filter if singularity problem.
|
% Go to univariate diffuse filter if singularity problem.
|
||||||
kalman_algo = 4;
|
singular_diffuse_filter
|
||||||
singularity_flag = 1;
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (kalman_algo==4)
|
if singular_diffuse_filter || (kalman_algo==4)
|
||||||
% Univariate Diffuse Kalman Filter
|
% Univariate Diffuse Kalman Filter
|
||||||
if isequal(H,0)
|
if isequal(H,0)
|
||||||
H = zeros(nobs,1);
|
H1 = zeros(nobs,1);
|
||||||
mmm = mm;
|
mmm = mm;
|
||||||
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;
|
||||||
else
|
else
|
||||||
Z = [Z, eye(pp)];
|
Z = [Z, eye(pp)];
|
||||||
|
@ -323,18 +323,20 @@ switch DynareOptions.lik_init
|
||||||
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(nobs,1);
|
H1 = zeros(nobs,1);
|
||||||
mmm = mm+pp;
|
mmm = mm+pp;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
% no need to test again for correlation elements
|
% no need to test again for correlation elements
|
||||||
correlated_errors_have_been_checked = 1;
|
correlated_errors_have_been_checked = 1;
|
||||||
|
|
||||||
[dLIK,dlik,a,Pstar] = univariate_kalman_filter_d(DynareDataset.missing.aindex,DynareDataset.missing.number_of_observations,DynareDataset.missing.no_more_missing_observations, ...
|
[dLIK,dlik,a,Pstar] = univariate_kalman_filter_d(DynareDataset.missing.aindex,...
|
||||||
|
DynareDataset.missing.number_of_observations,...
|
||||||
|
DynareDataset.missing.no_more_missing_observations, ...
|
||||||
Y, 1, size(Y,2), ...
|
Y, 1, size(Y,2), ...
|
||||||
zeros(mmm,1), Pinf, Pstar, ...
|
zeros(mmm,1), Pinf, Pstar, ...
|
||||||
kalman_tol, riccati_tol, DynareOptions.presample, ...
|
kalman_tol, riccati_tol, DynareOptions.presample, ...
|
||||||
T,R,Q,H,Z,mmm,pp,rr);
|
T,R,Q,H1,Z,mmm,pp,rr);
|
||||||
diffuse_periods = length(dlik);
|
diffuse_periods = length(dlik);
|
||||||
end
|
end
|
||||||
case 4% Start from the solution of the Riccati equation.
|
case 4% Start from the solution of the Riccati equation.
|
||||||
|
|
Loading…
Reference in New Issue