From e637319be5eb6436fea72fd9e49abd2a88dc557e Mon Sep 17 00:00:00 2001 From: Marco Ratto <marco.ratto@jrc.ec.europa.eu> Date: Fri, 14 Sep 2012 17:05:35 +0200 Subject: [PATCH] bug fix. the diffuse filter should simply penalize the likelihood with the NaN without breaking the estimation (this is in line with missing_observations_kalman_filter_d.m). --- matlab/dsge_likelihood.m | 7 +++++++ matlab/kalman/likelihood/univariate_kalman_filter_d.m | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/matlab/dsge_likelihood.m b/matlab/dsge_likelihood.m index 0aaee7215..c6ab3ccd9 100644 --- a/matlab/dsge_likelihood.m +++ b/matlab/dsge_likelihood.m @@ -427,6 +427,13 @@ switch DynareOptions.lik_init T,R,Q,H1,Z,mmm,pp,rr); diffuse_periods = length(dlik); end + if isnan(dLIK), + fval=dLIK; + info = 45; + exit_flag = 0; + return + end + case 4% Start from the solution of the Riccati equation. if kalman_algo ~= 2 kalman_algo = 1; diff --git a/matlab/kalman/likelihood/univariate_kalman_filter_d.m b/matlab/kalman/likelihood/univariate_kalman_filter_d.m index e983fd820..7bf16ef57 100644 --- a/matlab/kalman/likelihood/univariate_kalman_filter_d.m +++ b/matlab/kalman/likelihood/univariate_kalman_filter_d.m @@ -155,8 +155,8 @@ while newRank && (t<=last) end if (t>last) - error(['univariate_diffuse_kalman_filter:: There isn''t enough information to estimate the initial conditions of the nonstationary variables']); - LIK = NaN; + warning(['univariate_diffuse_kalman_filter:: There isn''t enough information to estimate the initial conditions of the nonstationary variables']); + dLIK = NaN; return end -- GitLab