Skip to content
Snippets Groups Projects
Commit 09f25415 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Merge branch 'PKF' into 'master'

Bug fixes for PKF

See merge request !2038
parents 5f403e9f cf548b46
Branches
Tags
1 merge request!2038Bug fixes for PKF
Pipeline #7097 passed
......@@ -61,11 +61,15 @@ function [a, a1, P, P1, v, T, R, C, regimes_, error_flag, M_, lik, etahat] = kal
warning off
regimes_=[]; %make sure it is always set
R=[];
C=[];
regimes_(1).regime=false;
regimes_(2).regime=false;
regimes_(3).regime=false;
regimes_(1).regimestart=NaN;
regimes_(2).regimestart=NaN;
regimes_(3).regimestart=NaN;
R=NaN(size(RR));
C=NaN(size(CC));
lik=Inf;
etahat=[];
sto.a=a;
sto.a1=a1;
......@@ -111,6 +115,8 @@ else
[a, a1, P, P1, v, alphahat, etahat, lik, error_flag] = occbin_kalman_update0(a,a1,P,P1,data_index,Z,v,Y,H,QQQ,TT,RR,CC,iF,L,mm, options_.rescale_prediction_error_covariance, options_.occbin.likelihood.IF_likelihood);
end
if error_flag
etahat=NaN(size(QQQ,1),1);
T=NaN(size(TT));
return;
end
......@@ -352,8 +358,8 @@ warning_config;
end
function [a, a1, P, P1, v, alphahat, etahat, lik, error_flag] = occbin_kalman_update0(a,a1,P,P1,data_index,Z,v,Y,H,QQQ,TT,RR,CC,iF,L,mm, rescale_prediction_error_covariance, IF_likelihood)
alphahat=[];
etahat=[];
alphahat=NaN(size(a));
etahat=NaN(size(QQQ,1),2);
lik=Inf;
error_flag=0;
......
......@@ -708,6 +708,12 @@ if ((kalman_algo==1) || (kalman_algo==3))% Multivariate Kalman Filter
DynareOptions.rescale_prediction_error_covariance, ...
DynareOptions.presample, ...
T,Q,R,H,Z,mm,pp,rr,Zflag,diffuse_periods, occbin_);
if occbin_.status && isinf(LIK)
fval = Inf;
info(1) = 320;
exit_flag = 0;
return
end
end
end
if analytic_derivation
......
......@@ -188,6 +188,8 @@ switch info(1)
message = 'Occbin: Simulation did not converge, increase maxit or check_ahead_periods.';
case 312
message = 'Occbin: Constraint(s) are binding at the end of the sample.';
case 320
message = 'Piecewise linear Kalman filter: There was a problem in obtaining the likelihood.';
otherwise
message = 'This case shouldn''t happen. Contact the authors of Dynare';
end
\ No newline at end of file
......@@ -232,7 +232,7 @@ while notsteady && t<=last
Qt = Qvec(:,:,t-1:t+1);
end
occbin_options.opts_simul.waitbar=0;
[ax, a1x, Px, P1x, vx, Tx, Rx, Cx, regimes_(t:t+2), info, M_, likx, etax(t,:)] = occbin.kalman_update_algo_1(a0(:,t-1),a1(:,t-1:t),P0(:,:,t-1),P1(:,:,t-1:t),data_index(t-1:t),Z,vv(:,t-1:t),Y(:,t-1:t),H,Qt,T0,R0,TT(:,:,t-1:t),RR(:,:,t-1:t),CC(:,t-1:t),regimes_(t:t+1),M_,oo_,options_,occbin_options);
[ax, a1x, Px, P1x, vx, Tx, Rx, Cx, regimes_(t:t+2), info, M_, likx] = occbin.kalman_update_algo_1(a0(:,t-1),a1(:,t-1:t),P0(:,:,t-1),P1(:,:,t-1:t),data_index(t-1:t),Z,vv(:,t-1:t),Y(:,t-1:t),H,Qt,T0,R0,TT(:,:,t-1:t),RR(:,:,t-1:t),CC(:,t-1:t),regimes_(t:t+1),M_,oo_,options_,occbin_options);
if info
return
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment