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

Merge branch 'kalman_update' into 'master'

:bug: fix loop in kalman_update_engine.m if regime_start hits 0

Closes #1956

See merge request !2348
parents d2ea7662 74fdf823
No related branches found
No related tags found
1 merge request!2348:bug: fix loop in kalman_update_engine.m if regime_start hits 0
Pipeline #11378 passed
...@@ -109,6 +109,7 @@ if info==0 ...@@ -109,6 +109,7 @@ if info==0
newstart = regx(1).regimestart(end); newstart = regx(1).regimestart(end);
diffstart = newstart-oldstart; diffstart = newstart-oldstart;
regname = 'regimestart'; regname = 'regimestart';
reg_string = 'regime';
else else
newstart1 = regx(1).regimestart1(end); newstart1 = regx(1).regimestart1(end);
newstart2 = regx(1).regimestart2(end); newstart2 = regx(1).regimestart2(end);
...@@ -118,11 +119,13 @@ if info==0 ...@@ -118,11 +119,13 @@ if info==0
switch diffregime switch diffregime
case 1 case 1
regname = 'regimestart1'; regname = 'regimestart1';
reg_string = 'regime1';
case 2 case 2
regname = 'regimestart2'; regname = 'regimestart2';
reg_string = 'regime2';
end
end end
end end
end
if options_.occbin.filter.use_relaxation && diffstart>options_.occbin.filter.use_relaxation if options_.occbin.filter.use_relaxation && diffstart>options_.occbin.filter.use_relaxation
guess_regime = [base_regime base_regime]; guess_regime = [base_regime base_regime];
options_.occbin.filter.guess_regime = true; options_.occbin.filter.guess_regime = true;
...@@ -132,9 +135,15 @@ if options_.occbin.filter.use_relaxation && diffstart>options_.occbin.filter.use ...@@ -132,9 +135,15 @@ if options_.occbin.filter.use_relaxation && diffstart>options_.occbin.filter.use
% we reduce length until the converged regime does not change % we reduce length until the converged regime does not change
guess_regime(1).(regname)(end) = regx2(1).(regname)(end)-1; guess_regime(1).(regname)(end) = regx2(1).(regname)(end)-1;
if guess_regime(1).(regname)(end-1)==guess_regime(1).(regname)(end) if guess_regime(1).(regname)(end)==1
guess_regime(1).(regname)(end-1) = guess_regime(1).(regname)(end-1)-1; % make sure we enforce base regime
end guess_regime(1).(regname)=guess_regime(1).(regname)(end);
guess_regime(1).(reg_string)=0;
else
if guess_regime(1).(regname)(end-1)==guess_regime(1).(regname)(end)
guess_regime(1).(regname)(end-1) = guess_regime(1).(regname)(end-1)-1;
end
end
if is_multivariate if is_multivariate
[ax2, a1x2, Px2, P1x2, vx2, Tx2, Rx2, Cx2, regx2, info2, M_2, likx2, etahat2, alphahat2, V2] = occbin.kalman_update_algo_1(a0,a1,P0,P1,data_index,Z,vv,Y,H,Qt,T0,R0,TT,RR,CC,guess_regime,M_,dr,endo_steady_state,exo_steady_state,exo_det_steady_state,options_,occbin_options); [ax2, a1x2, Px2, P1x2, vx2, Tx2, Rx2, Cx2, regx2, info2, M_2, likx2, etahat2, alphahat2, V2] = occbin.kalman_update_algo_1(a0,a1,P0,P1,data_index,Z,vv,Y,H,Qt,T0,R0,TT,RR,CC,guess_regime,M_,dr,endo_steady_state,exo_steady_state,exo_det_steady_state,options_,occbin_options);
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment