new error codes introduced and applied for occbin smoother.

- 321 when simulation within occbin smoother fails
- 322 when occbin smoother does not converge.
silicon
Marco Ratto 2023-02-06 14:58:42 +01:00
parent f565a0a84a
commit 63a299f64e
4 changed files with 18 additions and 5 deletions

View File

@ -147,7 +147,7 @@ options_.noprint = true;
if out.error_flag
fprintf('Occbin smoother:: simulation within smoother did not converge.\n')
print_info(out.error_flag, options_.noprint, options_)
oo_.occbin.smoother.error_flag=1;
oo_.occbin.smoother.error_flag=321;
return;
end
regime_history = out.regime_history;
@ -213,7 +213,7 @@ while is_changed && maxiter>iter && ~is_periodic
if out.error_flag
fprintf('Occbin smoother:: simulation within smoother did not converge.\n')
print_info(out.error_flag, false, options_)
oo_.occbin.smoother.error_flag=1;
oo_.occbin.smoother.error_flag=321;
return;
end
regime_history = out.regime_history;
@ -363,7 +363,7 @@ if (maxiter==iter && is_changed) || is_periodic
else
fprintf('occbin.DSGE_smoother: The respective fields in oo_ will be left empty.\n')
oo_.occbin.smoother=[];
oo_.occbin.smoother.error_flag=1;
oo_.occbin.smoother.error_flag=322;
end
else
disp('occbin.DSGE_smoother: smoother converged.')

View File

@ -194,8 +194,10 @@ if isequal(options_.mode_compute,0) && isempty(options_.mode_file) && ~options_.
else
if options_.occbin.smoother.status
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,M_,oo_,bayestopt_] = occbin.DSGE_smoother(xparam1,gend,transpose(data),data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_,dataset_,dataset_info);
if oo_.occbin.smoother.error_flag==0
if oo_.occbin.smoother.error_flag(1)==0
[oo_]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty);
else
fprintf('\nOccbin: smoother did not succeed. No results will be written to oo_.\n')
end
else
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,M_,oo_,bayestopt_] = DsgeSmoother(xparam1,gend,transpose(data),data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
@ -619,8 +621,10 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
else
if options_.occbin.smoother.status
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,M_,oo_,bayestopt_] = occbin.DSGE_smoother(xparam1,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_,dataset_,dataset_info);
if oo_.occbin.smoother.error_flag==0
if oo_.occbin.smoother.error_flag(1)==0
[oo_,yf]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty);
else
fprintf('\nOccbin: smoother did not succeed. No results will be written to oo_.\n')
end
else
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,M_,oo_,bayestopt_] = DsgeSmoother(xparam1,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_);

View File

@ -192,6 +192,10 @@ switch info(1)
message = 'Occbin: Simulation did not converge -- infinite loop of guess regimes';
case 320
message = 'Piecewise linear Kalman filter: There was a problem in obtaining the likelihood.';
case 321
message = 'Occbin: there was a problem in running the smoother. Simulation within smoother failed.';
case 322
message = 'Occbin: smoother did not converge.';
case 401
message = 'Cycle reduction reached the iteration limit. Try increasing maxit.';
case 402

View File

@ -226,8 +226,13 @@ for b=fpar:B
if options_.occbin.smoother.status
opts_local.occbin.simul.waitbar=0;
opts_local.occbin.smoother.waitbar = 0;
opts_local.occbin.smoother.linear_smoother=false; % speed-up
[alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,M_,oo_,bayestopt_] = ...
occbin.DSGE_smoother(deep,gend,Y,data_index,missing_value,M_,oo_,opts_local,bayestopt_,estim_params_);
if oo_.occbin.smoother.error_flag(1)
message=get_error_message(oo_.occbin.smoother.error_flag,opts_local);
fprintf('\nprior_posterior_statistics: One of the draws failed with the error:\n%s\n',message)
end
else
[alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,M_,oo_,bayestopt_] = ...
DsgeSmoother(deep,gend,Y,data_index,missing_value,M_,oo_,opts_local,bayestopt_,estim_params_);