OccBin: improve consistency - Make name of opts_simul subfield homogeneous for likelihood computation and smoother - fill the new field opts_regime with init_binding_indicator init_regime_history, to avoid possible conflics with simulations done in realtime filtering steps - smoother: use init_binding_indicator and init_regime_history options set in options_.occbin.smoother
parent
ac346ef83d
commit
d7ae0d0039
|
@ -119,9 +119,9 @@ opts_simul.piecewise_only = options_.occbin.smoother.piecewise_only;
|
||||||
occbin_options = struct();
|
occbin_options = struct();
|
||||||
|
|
||||||
occbin_options.first_period_occbin_update = options_.occbin.smoother.first_period_occbin_update;
|
occbin_options.first_period_occbin_update = options_.occbin.smoother.first_period_occbin_update;
|
||||||
occbin_options.opts_regime = opts_simul; % this builds the opts_simul options field needed by occbin.solver
|
occbin_options.opts_simul = opts_simul; % this builds the opts_simul options field needed by occbin.solver
|
||||||
occbin_options.opts_regime.binding_indicator = options_.occbin.likelihood.init_binding_indicator;
|
occbin_options.opts_regime.binding_indicator = options_.occbin.smoother.init_binding_indicator;
|
||||||
occbin_options.opts_regime.regime_history=options_.occbin.likelihood.init_regime_history;
|
occbin_options.opts_regime.regime_history=options_.occbin.smoother.init_regime_history;
|
||||||
|
|
||||||
error_indicator=false;
|
error_indicator=false;
|
||||||
try
|
try
|
||||||
|
@ -133,7 +133,7 @@ catch ME
|
||||||
for iter = 1:numel(ME.stack)
|
for iter = 1:numel(ME.stack)
|
||||||
ME.stack(iter)
|
ME.stack(iter)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if error_indicator || isempty(alphahat0)
|
if error_indicator || isempty(alphahat0)
|
||||||
etahat= oo_.occbin.linear_smoother.etahat;
|
etahat= oo_.occbin.linear_smoother.etahat;
|
||||||
alphahat0= oo_.occbin.linear_smoother.alphahat0;
|
alphahat0= oo_.occbin.linear_smoother.alphahat0;
|
||||||
|
@ -299,13 +299,13 @@ while is_changed && maxiter>iter && ~is_periodic
|
||||||
eee(:,k) = eig(TT(:,:,k));
|
eee(:,k) = eig(TT(:,:,k));
|
||||||
end
|
end
|
||||||
if options_.debug
|
if options_.debug
|
||||||
err_eig(iter-1) = max(max(abs(sort(eee)-sort(sto_eee))));
|
err_eig(iter-1) = max(max(abs(sort(eee)-sort(sto_eee))));
|
||||||
err_alphahat(iter-1) = max(max(max(abs(alphahat-sto_alphahat))));
|
err_alphahat(iter-1) = max(max(max(abs(alphahat-sto_alphahat))));
|
||||||
err_etahat(iter-1) = max(max(max(abs(etahat-sto_etahat{iter-1}))));
|
err_etahat(iter-1) = max(max(max(abs(etahat-sto_etahat{iter-1}))));
|
||||||
err_CC(iter-1) = max(max(max(abs(CC-sto_CC))));
|
err_CC(iter-1) = max(max(max(abs(CC-sto_CC))));
|
||||||
err_RR(iter-1) = max(max(max(abs(RR-sto_RR))));
|
err_RR(iter-1) = max(max(max(abs(RR-sto_RR))));
|
||||||
err_TT(iter-1) = max(max(max(abs(TT-sto_TT))));
|
err_TT(iter-1) = max(max(max(abs(TT-sto_TT))));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if occbin_smoother_debug || is_periodic
|
if occbin_smoother_debug || is_periodic
|
||||||
|
@ -483,15 +483,15 @@ if (~is_changed || occbin_smoother_debug) && nargin==12
|
||||||
fprintf(fidTeX,'\\label{Fig:smoothedshocks_occbin:%s}\n',int2str(ifig));
|
fprintf(fidTeX,'\\label{Fig:smoothedshocks_occbin:%s}\n',int2str(ifig));
|
||||||
fprintf(fidTeX,'\\end{figure}\n');
|
fprintf(fidTeX,'\\end{figure}\n');
|
||||||
fprintf(fidTeX,' \n');
|
fprintf(fidTeX,' \n');
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if mod(j1,9)~=0 && j==M_.exo_nbr
|
if mod(j1,9)~=0 && j==M_.exo_nbr
|
||||||
annotation('textbox', [0.1,0,0.35,0.05],'String', 'Linear','Color','Blue','horizontalalignment','center','interpreter','none');
|
annotation('textbox', [0.1,0,0.35,0.05],'String', 'Linear','Color','Blue','horizontalalignment','center','interpreter','none');
|
||||||
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Piecewise','Color','Red','horizontalalignment','center','interpreter','none');
|
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Piecewise','Color','Red','horizontalalignment','center','interpreter','none');
|
||||||
dyn_saveas(hh_fig,[GraphDirectoryName filesep M_.fname,'_smoothedshocks_occbin',int2str(ifig)],options_.nodisplay,options_.graph_format);
|
dyn_saveas(hh_fig,[GraphDirectoryName filesep M_.fname,'_smoothedshocks_occbin',int2str(ifig)],options_.nodisplay,options_.graph_format);
|
||||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||||
% TeX eps loader file
|
% TeX eps loader file
|
||||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||||
|
@ -505,6 +505,6 @@ if (~is_changed || occbin_smoother_debug) && nargin==12
|
||||||
end
|
end
|
||||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||||
fclose(fidTeX);
|
fclose(fidTeX);
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -85,7 +85,7 @@ if isempty(nk)
|
||||||
end
|
end
|
||||||
nk=max(nk,1);
|
nk=max(nk,1);
|
||||||
|
|
||||||
opts_simul = occbin_options.opts_regime;
|
opts_simul = occbin_options.opts_simul;
|
||||||
options_.occbin.simul=opts_simul;
|
options_.occbin.simul=opts_simul;
|
||||||
base_regime = struct();
|
base_regime = struct();
|
||||||
if M_.occbin.constraint_nbr==1
|
if M_.occbin.constraint_nbr==1
|
||||||
|
@ -383,4 +383,4 @@ while t > 1
|
||||||
ri = T'*ri; % KD (2003), eq. (23), equation for r_{t-1,p_{t-1}}
|
ri = T'*ri; % KD (2003), eq. (23), equation for r_{t-1,p_{t-1}}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -906,7 +906,5 @@ occbin_options.opts_simul.restrict_state_space = options_.occbin.likelihood.rest
|
||||||
|
|
||||||
occbin_options.opts_simul.full_output = options_.occbin.likelihood.full_output;
|
occbin_options.opts_simul.full_output = options_.occbin.likelihood.full_output;
|
||||||
occbin_options.opts_simul.piecewise_only = options_.occbin.likelihood.piecewise_only;
|
occbin_options.opts_simul.piecewise_only = options_.occbin.likelihood.piecewise_only;
|
||||||
if ~isempty(options_.occbin.smoother.init_binding_indicator)
|
occbin_options.opts_regime.init_binding_indicator = options_.occbin.likelihood.init_binding_indicator;
|
||||||
occbin_options.opts_simul.init_binding_indicator = options_.occbin.likelihood.init_binding_indicator;
|
occbin_options.opts_regime.init_regime_history=options_.occbin.likelihood.init_regime_history;
|
||||||
occbin_options.opts_simul.init_regime_history=options_.occbin.likelihood.init_regime_history;
|
|
||||||
end
|
|
||||||
|
|
|
@ -109,8 +109,8 @@ if occbin_.status
|
||||||
M_=occbin_.info{6};
|
M_=occbin_.info{6};
|
||||||
occbin_options=occbin_.info{7};
|
occbin_options=occbin_.info{7};
|
||||||
occbin_options.opts_simul.SHOCKS = [];
|
occbin_options.opts_simul.SHOCKS = [];
|
||||||
opts_regime.regime_history = occbin_options.opts_simul.init_regime;
|
opts_regime.regime_history = occbin_options.opts_regime.init_regime_history;
|
||||||
opts_regime.binding_indicator = occbin_options.opts_simul.init_binding_indicator;
|
opts_regime.binding_indicator = occbin_options.opts_regime.init_binding_indicator;
|
||||||
if t>1
|
if t>1
|
||||||
first_period_occbin_update = max(t+1,options_.occbin.likelihood.first_period_occbin_update);
|
first_period_occbin_update = max(t+1,options_.occbin.likelihood.first_period_occbin_update);
|
||||||
else
|
else
|
||||||
|
|
|
@ -348,7 +348,7 @@ if isoccbin
|
||||||
first_period_occbin_update = max(t+2,occbin_options.first_period_occbin_update);
|
first_period_occbin_update = max(t+2,occbin_options.first_period_occbin_update);
|
||||||
% kalman update is not yet robust to accommodate diffuse steps
|
% kalman update is not yet robust to accommodate diffuse steps
|
||||||
end
|
end
|
||||||
if occbin_options.opts_regime.waitbar && first_period_occbin_update<smpl
|
if occbin_options.opts_simul.waitbar && first_period_occbin_update<smpl
|
||||||
hh_fig = dyn_waitbar(0,'Occbin: Piecewise Kalman Filter');
|
hh_fig = dyn_waitbar(0,'Occbin: Piecewise Kalman Filter');
|
||||||
set(hh_fig,'Name','Occbin: Piecewise Kalman Filter.');
|
set(hh_fig,'Name','Occbin: Piecewise Kalman Filter.');
|
||||||
waitbar_indicator=1;
|
waitbar_indicator=1;
|
||||||
|
@ -381,7 +381,7 @@ while notsteady && t<smpl
|
||||||
if waitbar_indicator
|
if waitbar_indicator
|
||||||
dyn_waitbar(t/smpl, hh_fig, sprintf('Period %u of %u', t,smpl));
|
dyn_waitbar(t/smpl, hh_fig, sprintf('Period %u of %u', t,smpl));
|
||||||
end
|
end
|
||||||
occbin_options.opts_regime.waitbar=0;
|
occbin_options.opts_simul.waitbar=0;
|
||||||
if t==1
|
if t==1
|
||||||
if isqvec
|
if isqvec
|
||||||
Qt = cat(3,Q,Qvec(:,:,t:t+1));
|
Qt = cat(3,Q,Qvec(:,:,t:t+1));
|
||||||
|
@ -532,7 +532,7 @@ while notsteady && t<smpl
|
||||||
end
|
end
|
||||||
aK(1,:,t+1) = a1(:,t+1);
|
aK(1,:,t+1) = a1(:,t+1);
|
||||||
if ~isempty(nk) && nk>1 && isoccbin && (t>=first_period_occbin_update || isinf(first_period_occbin_update))
|
if ~isempty(nk) && nk>1 && isoccbin && (t>=first_period_occbin_update || isinf(first_period_occbin_update))
|
||||||
opts_simul = occbin_options.opts_regime;
|
opts_simul = occbin_options.opts_simul;
|
||||||
opts_simul.SHOCKS = zeros(nk,M_.exo_nbr);
|
opts_simul.SHOCKS = zeros(nk,M_.exo_nbr);
|
||||||
if smoother_redux
|
if smoother_redux
|
||||||
tmp=zeros(M_.endo_nbr,1);
|
tmp=zeros(M_.endo_nbr,1);
|
||||||
|
|
Loading…
Reference in New Issue