Occbin forecast issue

Good morning, dear community.

I am trying to perform forecasting in a model with Occasionally Binding Constraints. The guide code I am using is: tests/occbin/filter · master · Dynare / dynare · GitLab

My code estimates well, but it stops at the forecast1 part:

options_.occbin.smoother.debug=1;
    occbin_setup(filter_use_relaxation,likelihood_piecewise_kalman_filter);
    // use PKF  
    estimation(
            %datafile=dataobsfile2, 
            datafile = 'base_fiscal_anual_URY2.xlsx', xls_sheet = Base_Modelo, xls_range = A1:AF32, nobs = 22,
            mode_file=FISLAC_2_URY_OCCBIN_mh_mode,
            mode_compute=0, first_obs=1,
            mh_replic=0, plot_priors=0, smoother,
            consider_all_endogenous,heteroskedastic_filter,filter_step_ahead=[1],smoothed_state_uncertainty);    

   // plot regimes
   occbin.plot_regimes(oo_.occbin.smoother.regime_history,M_,options_)

   // forecast starting from period 22, zero shocks (default)
   smoother2histval(period=10);
   [forecast, error_flag] = occbin.forecast(options_,M_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state,8);
   // forecast with stochastic shocks
   options_.occbin.forecast.qmc=true;
   options_.occbin.forecast.replic=46;
   [forecast1, error_flag] = occbin.forecast(options_,M_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state,8);

And the error says:

Arrays have incompatible sizes for this operation.
Error in occbin.forecast (line 101)
        options_.occbin.simul.SHOCKS = shocks_base+transpose(U*sqrt(S)*SHOCKS_add(:,:,iter));
Error in FISLAC_2_URY_OCCBIN.driver (line 2381)
[forecast1, error_flag] = occbin.forecast(options_,M_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state,8);
Error in dynare (line 310)
    evalin('base',[fname '.driver']);

Upon reviewing the dimensionality of the relevant matrices, I have the following sizes for the calculation line that caused the error: shocks_base (46x48) + transpose...(46x48). Therefore, I am unsure why the dimensionality error is being reported.

M_.Sigma_e=48x48
forecast_horizon=46
M_.exo_nbr=48

Thanks a lot.

Best regards

Thanks for reporting. Can you provide me with the full codes to replicate the issue?

A bug fix is at 🐛 occbin.forecast: account for zero variance shocks and do not crash if one simulation fails (!2304) · Merge requests · Dynare / dynare · GitLab

After fixing that, I get convergence issues in the simulation with periodic solutions for random shocks.

That was the problem! and now it works very well. I changed a few parameter estimations in my code, and the forecast runs without a problem.

You were very kind, and thank you so much!