Added trap for cases where diffuse filters fail (replaced error messages by warning messages).

time-shift
Stéphane Adjemian (Charybdis) 2010-02-05 23:18:08 +01:00
parent 55c210ef47
commit 3f1fad9cd2
7 changed files with 29 additions and 13 deletions

View File

@ -21,7 +21,7 @@ function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data
% SPECIAL REQUIREMENTS
%
% Copyright (C) 2004-2009 Dynare Team
% Copyright (C) 2004-2009, 2010 Dynare Team
%
% This file is part of Dynare.
%
@ -314,7 +314,11 @@ if (kalman_algo==4)% Univariate Diffuse Kalman Filter
no_more_missing_observations);
end
end
if imag(LIK) ~= 0
if isnan(LIK)
cost_flag = 0;
return
end
if imag(LIK)~=0
likelihood = bayestopt_.penalty;
else
likelihood = LIK;

View File

@ -23,7 +23,7 @@ function [LIK, lik] = diffuse_kalman_filter(T,R,Q,H,Pinf,Pstar,Y,start,Z,kalman_
% Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
% Analysis, vol. 24(1), pp. 85-98).
% Copyright (C) 2004-2008 Dynare Team
% Copyright (C) 2004-2008, 2010 Dynare Team
%
% This file is part of Dynare.
%
@ -95,7 +95,9 @@ while rank(Pinf,kalman_tol) && (t<smpl)
end
if t == smpl
error(['There isn''t enough information to estimate the initial conditions of the nonstationary variables']);
warning(['There isn''t enough information to estimate the initial conditions of the nonstationary variables']);
LIK = NaN;
return
end
F_singular = 1;
@ -125,7 +127,9 @@ while notsteady && (t<smpl)
end
if F_singular == 1
error(['The variance of the forecast error remains singular until the end of the sample'])
warning(['The variance of the forecast error remains singular until the end of the sample'])
LIK = NaN;
return
end
if t < smpl

View File

@ -27,7 +27,7 @@ function [LIK, lik] = missing_observations_diffuse_kalman_filter(T,R,Q,H,Pinf,Ps
% Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
% Analysis, vol. 24(1), pp. 85-98).
% Copyright (C) 2004-2008 Dynare Team
% Copyright (C) 2004-2008, 2010 Dynare Team
%
% This file is part of Dynare.
%
@ -111,7 +111,9 @@ while rank(Pinf,kalman_tol) && (t<smpl)
end
if t == smpl
error(['There isn''t enough information to estimate the initial conditions of the nonstationary variables']);
warning(['There isn''t enough information to estimate the initial conditions of the nonstationary variables']);
LIK = NaN;
return
end
F_singular = 1;
@ -155,7 +157,9 @@ while notsteady && (t<smpl)
end
if F_singular == 1
error(['The variance of the forecast error remains singular until the end of the sample'])
warning(['The variance of the forecast error remains singular until the end of the sample'])
LIK = NaN;
return
end
if t < smpl

View File

@ -28,7 +28,7 @@ function [LIK, lik] = univariate_diffuse_kalman_filter(T,R,Q,H,Pinf,Pstar,Y,star
% NOTES
% The vector "lik" is used to evaluate the jacobian of the likelihood.
% Copyright (C) 2004-2009 Dynare Team
% Copyright (C) 2004-2009, 2010 Dynare Team
%
% This file is part of Dynare.
%
@ -100,6 +100,8 @@ end
if (t==smpl)
error(['univariate_diffuse_kalman_filter:: There isn''t enough information to estimate the initial conditions of the nonstationary variables']);
LIK = NaN;
return
end
while notsteady && (t<smpl)

View File

@ -29,7 +29,7 @@ function [LIK, lik] = univariate_diffuse_kalman_filter_corr(T,R,Q,H,Pinf,Pstar,Y
% NOTES
% The vector "lik" is used to evaluate the jacobian of the likelihood.
% Copyright (C) 2004-2008 Dynare Team
% Copyright (C) 2004-2008, 2010 Dynare Team
%
% This file is part of Dynare.
%
@ -148,7 +148,9 @@ while newRank && (t<smpl)
end
if (t==smpl)
error(['univariate_diffuse_kalman_filter:: There isn''t enough information to estimate the initial conditions of the nonstationary variables']);
warning(['univariate_diffuse_kalman_filter:: There isn''t enough information to estimate the initial conditions of the nonstationary variables']);
LIK = NaN;
return
end
while notsteady && (t<smpl)

View File

@ -28,7 +28,7 @@ function [LIK, lik] = univariate_kalman_filter(T,R,Q,H,P,Y,start,mf,kalman_tol,r
% NOTES
% The vector "lik" is used to evaluate the jacobian of the likelihood.
% Copyright (C) 2004-2008 Dynare Team
% Copyright (C) 2004-2008, 2010 Dynare Team
%
% This file is part of Dynare.
%

View File

@ -18,7 +18,7 @@ function mode_check(x,fval,hessian,gend,data,lb,ub,data_index,number_of_observat
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-2009 Dynare Team
% Copyright (C) 2003-2009, 2010 Dynare Team
%
% This file is part of Dynare.
%