From 75e52ed71d4927d71409e1d98976aa504e4c76d1 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sun, 19 Jun 2016 17:00:05 +0200 Subject: [PATCH] Make sure fast_kalman_filter is only used with diffuse_periods=0 Closes #1234 --- doc/dynare.texi | 5 +++-- matlab/dsge_likelihood.m | 11 +++++++++++ matlab/print_info.m | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index c7987b7fa..6de243511 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -5849,8 +5849,9 @@ singularity is encountered, Dynare by default automatically switches to the univ @item fast_kalman_filter @anchor{fast_kalman_filter} Select the fast Kalman filter using Chandrasekhar recursions as described by @cite{Herbst, 2015}. This setting is only used with -@code{kalman_algo=1} or @code{kalman_algo=3}. It is not yet compatible with -@code{analytical_derivation}. +@code{kalman_algo=1} or @code{kalman_algo=3}. In case of using the diffuse Kalman +filter (@code{kalman_algo=3/lik_init=3}), the observables must be stationary. This option +is not yet compatible with @code{analytical_derivation}. @item kalman_tol = @var{DOUBLE} @anchor{kalman_tol} Numerical tolerance for determining the singularity of the covariance matrix of the prediction errors during the Kalman filter (minimum allowed reciprocal of the matrix condition number). Default value is @code{1e-10} diff --git a/matlab/dsge_likelihood.m b/matlab/dsge_likelihood.m index 09952053a..342a9b555 100644 --- a/matlab/dsge_likelihood.m +++ b/matlab/dsge_likelihood.m @@ -655,6 +655,17 @@ if ((kalman_algo==1) || (kalman_algo==3))% Multivariate Kalman Filter [err, LIK] = block_kalman_filter(T,R,Q,H,Pstar,Y,start,Z,kalman_tol,riccati_tol, Model.nz_state_var, Model.n_diag, Model.nobs_non_statevar); mexErrCheck('block_kalman_filter', err); elseif DynareOptions.fast_kalman_filter + if diffuse_periods + %kalman_algo==3 requires no diffuse periods (stationary + %observables) as otherwise FE matrix will not be positive + %definite + fval = Inf; + info(1) = 55; + info(4) = 0.1; + exit_flag = 0; + return + end + [LIK,lik] = kalman_filter_fast(Y,diffuse_periods+1,size(Y,2), ... a,Pstar, ... kalman_tol, riccati_tol, ... diff --git a/matlab/print_info.m b/matlab/print_info.m index e9985998d..1457e3945 100644 --- a/matlab/print_info.m +++ b/matlab/print_info.m @@ -123,6 +123,8 @@ if ~noprint error('You are estimating a DSGE-VAR model, but the value of the dsge prior weight is too low!') case 52 %dsge_var_likelihood error('You are estimating a DSGE-VAR model, but the implied covariance matrix of the VAR''s innovations is not positive definite!'); + case 55 + error('Fast Kalman filter only works with stationary models [lik_init=1] or stationary observables for non-stationary models [lik_init=3]') case 61 %Discretionary policy error(['Discretionary policy: maximum number of iterations has been reached. Procedure failed. ']); case 62